codex-overleaf-link 2.1.2 → 2.1.4
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 +23 -23
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/src/content/contentRuntime.js +2 -2
- package/extension/src/content/modelPicker.js +5 -1
- package/extension/src/content/providerSettingsCoordinator.js +5 -1
- package/extension/src/content/runController.js +2 -1
- package/extension/src/content/writebackController.js +3 -3
- package/extension/src/shared/agentTranscript.js +23 -23
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/sessionState.js +3 -0
- package/native-host/src/codexRuntimeIdentity.js +217 -0
- package/native-host/src/nativeDoctor.js +40 -0
- package/native-host/src/nativeEnvironment.js +28 -1
- package/native-host/src/taskRunnerRuntime.js +30 -17
- package/package.json +1 -1
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.
|
|
6
|
+
<img src="https://img.shields.io/badge/version-2.1.4-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.
|
|
41
|
+
CODEX_OVERLEAF_REF=v2.1.4 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.4/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.
|
|
48
|
-
$env:CODEX_OVERLEAF_REF='v2.1.
|
|
47
|
+
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.4/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v2.1.4'
|
|
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.
|
|
59
|
+
npm exec --yes codex-overleaf-link@2.1.4 -- 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.
|
|
90
|
-
| Diagnose | `npm exec --yes codex-overleaf-link@2.1.
|
|
91
|
-
| Uninstall | `npm exec --yes codex-overleaf-link@2.1.
|
|
89
|
+
| Install / update | `npm exec --yes codex-overleaf-link@2.1.4 -- install-managed` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@2.1.4 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@2.1.4 -- 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.
|
|
101
|
+
The v2.1.4 GitHub Release contains:
|
|
102
102
|
|
|
103
|
-
- `codex-overleaf-link-extension-v2.1.
|
|
104
|
-
- `codex-overleaf-native-host-v2.1.
|
|
105
|
-
- `codex-overleaf-link-2.1.
|
|
106
|
-
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v2.1.
|
|
107
|
-
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.1.
|
|
103
|
+
- `codex-overleaf-link-extension-v2.1.4.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v2.1.4.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-2.1.4.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.4` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v2.1.4` 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.
|
|
118
|
+
npm exec --yes codex-overleaf-link@2.1.4 -- 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.
|
|
153
|
+
CODEX_OVERLEAF_REF=v2.1.4 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v2.1.4/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.
|
|
159
|
+
npm exec --yes codex-overleaf-link@2.1.4 -- 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.
|
|
295
|
+
npm exec --yes codex-overleaf-link@2.1.4 -- 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.
|
|
345
|
-
| Uninstall command | `npm exec --yes codex-overleaf-link@2.1.
|
|
344
|
+
| Installer/update command | `npm exec --yes codex-overleaf-link@2.1.4 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.4 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.4 -- install-managed` | `npm exec --yes codex-overleaf-link@2.1.4 -- install-managed --browser chromium` |
|
|
345
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@2.1.4 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.4 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.4 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@2.1.4 -- 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.
|
|
381
|
+
npm exec --yes codex-overleaf-link@2.1.4 -- 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.
|
|
391
|
+
npm exec --yes codex-overleaf-link@2.1.4 -- 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.
|
|
397
|
+
npm exec --yes codex-overleaf-link@2.1.4 -- uninstall-native
|
|
398
398
|
```
|
|
@@ -604,7 +604,7 @@
|
|
|
604
604
|
window,
|
|
605
605
|
getSettingsPanelInstance: () => settingsPanelInstance,
|
|
606
606
|
getSelectedModel: () => state?.model || '', getSelectedProviderId: () => state?.providerId || 'builtin',
|
|
607
|
-
setSelectedProviderId: providerId => { state = updateActiveSession(state, { providerId: providerId || 'builtin' }); },
|
|
607
|
+
setSelectedProviderId: (providerId, model) => { state = updateActiveSession(state, { providerId: providerId || 'builtin', ...(model !== undefined ? { model } : {}) }); const modelSelect = panel?.querySelector('[data-model]'); if (model !== undefined && modelSelect) modelSelect.value = ''; },
|
|
608
608
|
refreshModelOptions: loadModelOptions, persistInputs: persistPanelInputs
|
|
609
609
|
});
|
|
610
610
|
// v1.8.1 D3: the dashboard was a one-shot render — another tab finishing a
|
|
@@ -6313,7 +6313,7 @@
|
|
|
6313
6313
|
saveStateSoon();
|
|
6314
6314
|
return;
|
|
6315
6315
|
}
|
|
6316
|
-
renderReasoningOptions(getRenderedModelEntries());
|
|
6316
|
+
if (event?.target?.matches?.('[data-speed]')) state = updateActiveSession(state, { speedTier: readSelectedSpeedInput() }); renderReasoningOptions(getRenderedModelEntries());
|
|
6317
6317
|
renderSpeedOptions(getRenderedModelEntries());
|
|
6318
6318
|
readPanelInputs();
|
|
6319
6319
|
renderModelConfigChoices();
|
|
@@ -83,20 +83,24 @@
|
|
|
83
83
|
const modelSelect = getPanel()?.querySelector('[data-model]');
|
|
84
84
|
const reasoningSelect = getPanel()?.querySelector('[data-reasoning]');
|
|
85
85
|
const speedSelect = getPanel()?.querySelector('[data-speed]');
|
|
86
|
+
let changedInput = null;
|
|
86
87
|
|
|
87
88
|
if (choice.dataset.reasoningChoice && reasoningSelect) {
|
|
88
89
|
reasoningSelect.value = choice.dataset.reasoningChoice;
|
|
90
|
+
changedInput = reasoningSelect;
|
|
89
91
|
} else if (choice.dataset.modelChoice && modelSelect) {
|
|
90
92
|
modelSelect.value = choice.dataset.modelChoice;
|
|
93
|
+
changedInput = modelSelect;
|
|
91
94
|
renderReasoningOptions(getRenderedModelEntries());
|
|
92
95
|
renderSpeedOptions(getRenderedModelEntries());
|
|
93
96
|
} else if (choice.dataset.speedChoice && speedSelect) {
|
|
94
97
|
speedSelect.value = choice.dataset.speedChoice;
|
|
98
|
+
changedInput = speedSelect;
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
renderModelConfigChoices();
|
|
98
102
|
updateModelDisplay();
|
|
99
|
-
await persistPanelInputs();
|
|
103
|
+
await persistPanelInputs(changedInput ? { type: 'change', target: changedInput } : undefined);
|
|
100
104
|
}
|
|
101
105
|
async function loadModelOptions(providerSelection) {
|
|
102
106
|
const generation = ++modelLoadGeneration;
|
|
@@ -111,7 +111,11 @@
|
|
|
111
111
|
: previousProviderId;
|
|
112
112
|
const sessionProviderChanged = requestedProviderId !== previousProviderId;
|
|
113
113
|
if (sessionProviderChanged) {
|
|
114
|
-
|
|
114
|
+
const requestedProvider = window.CodexOverleafProviderProfiles.getProviderById(catalog, requestedProviderId);
|
|
115
|
+
const preferredModelId = requestedProvider?.kind === 'custom'
|
|
116
|
+
? requestedProvider.defaultModelId || requestedProvider.models?.[0]?.id || ''
|
|
117
|
+
: '';
|
|
118
|
+
instance.setSelectedProviderId(requestedProviderId, preferredModelId);
|
|
115
119
|
}
|
|
116
120
|
const changedProviderIds = Array.isArray(change.changedProviderIds) ? change.changedProviderIds : [];
|
|
117
121
|
if (!change.forceSessionRefresh && !sessionProviderChanged && !changedProviderIds.includes(requestedProviderId)) {
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
model: state.model,
|
|
50
50
|
reasoningEffort: state.reasoningEffort,
|
|
51
51
|
speedTier: state.speedTier,
|
|
52
|
+
locale: state.locale === 'zh' ? 'zh' : 'en',
|
|
52
53
|
session: state.session,
|
|
53
54
|
threadId: codexThreadId || undefined,
|
|
54
55
|
customInstructions: normalizedCustomInstructions || undefined,
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
return params;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
function buildSessionHistoryResult({ assistantMessage = '', syncOutcome = {}, syncChanges = [], locale = '
|
|
74
|
+
function buildSessionHistoryResult({ assistantMessage = '', syncOutcome = {}, syncChanges = [], locale = 'en' } = {}) {
|
|
74
75
|
const parts = [];
|
|
75
76
|
const finalAnswer = truncateSessionHistoryText(assistantMessage, 1600);
|
|
76
77
|
if (finalAnswer) {
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
function formatUnsupportedLocalChangeSummary(changes = [], locale = '
|
|
196
|
+
function formatUnsupportedLocalChangeSummary(changes = [], locale = 'en') {
|
|
197
197
|
if (!changes.length) {
|
|
198
198
|
return '';
|
|
199
199
|
}
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
return lines.join('\n');
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
function formatUnsupportedLocalChangeReason(changeOrReason, locale = '
|
|
221
|
+
function formatUnsupportedLocalChangeReason(changeOrReason, locale = 'en') {
|
|
222
222
|
const isEnglish = locale === 'en';
|
|
223
223
|
const change = typeof changeOrReason === 'object' && changeOrReason
|
|
224
224
|
? changeOrReason
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
: '当前类型暂不支持自动写回。';
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
function formatBinaryPayloadLimitReason(change = {}, locale = '
|
|
250
|
+
function formatBinaryPayloadLimitReason(change = {}, locale = 'en') {
|
|
251
251
|
const isEnglish = locale === 'en';
|
|
252
252
|
const size = formatBytes(change.size);
|
|
253
253
|
const limit = formatBytes(change.limit || change.aggregateLimit || change.nativeOutputLimit);
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
function normalizeLocale(options = {}) {
|
|
52
|
-
return options?.locale === '
|
|
52
|
+
return options?.locale === 'zh' ? 'zh' : 'en';
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
function textFor(locale, zh, en) {
|
|
@@ -430,7 +430,7 @@
|
|
|
430
430
|
&& /(context|thread|turn|conversation|codex)/i.test(label);
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
-
function formatContextCompactionCheckpoint(event = {}, locale = '
|
|
433
|
+
function formatContextCompactionCheckpoint(event = {}, locale = 'en') {
|
|
434
434
|
const method = String(event.detail?.method || event.title || '');
|
|
435
435
|
const running = event.status === 'running' || /(started|starting|begin|prepar)/i.test(method);
|
|
436
436
|
return {
|
|
@@ -559,7 +559,7 @@
|
|
|
559
559
|
return `${prefix}:${itemId || 'current'}`;
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
function formatPlanUpdateTitle(params = {}, locale = '
|
|
562
|
+
function formatPlanUpdateTitle(params = {}, locale = 'en') {
|
|
563
563
|
const steps = Array.isArray(params.plan) ? params.plan : [];
|
|
564
564
|
const active = steps.find(step => step.status === 'in_progress') || steps.find(step => step.status === 'pending');
|
|
565
565
|
const text = cleanVisibleText(active?.step || params.explanation || '');
|
|
@@ -568,7 +568,7 @@
|
|
|
568
568
|
: textFor(locale, 'Codex 更新了执行计划。', 'Codex updated its plan.');
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
-
function formatPlanUpdateDetail(params = {}, locale = '
|
|
571
|
+
function formatPlanUpdateDetail(params = {}, locale = 'en') {
|
|
572
572
|
const steps = Array.isArray(params.plan) ? params.plan : [];
|
|
573
573
|
if (!steps.length) {
|
|
574
574
|
return undefined;
|
|
@@ -892,7 +892,7 @@
|
|
|
892
892
|
* part of Codex's answer. `formatHumanReport` retains the legacy flat-text
|
|
893
893
|
* shape for transcripts, storage fallback, and existing assertions.
|
|
894
894
|
*/
|
|
895
|
-
function buildStructuredHumanReport(report = {}, locale = '
|
|
895
|
+
function buildStructuredHumanReport(report = {}, locale = 'en') {
|
|
896
896
|
const conclusion = cleanVisibleMarkdownText(report.conclusion || '');
|
|
897
897
|
|
|
898
898
|
const bodySections = [];
|
|
@@ -939,7 +939,7 @@
|
|
|
939
939
|
return { conclusion, body: bodySections.join('\n\n'), meta };
|
|
940
940
|
}
|
|
941
941
|
|
|
942
|
-
function formatHumanReport(report = {}, locale = '
|
|
942
|
+
function formatHumanReport(report = {}, locale = 'en') {
|
|
943
943
|
const sections = [];
|
|
944
944
|
const conclusion = cleanVisibleMarkdownText(report.conclusion || '');
|
|
945
945
|
if (conclusion) {
|
|
@@ -969,7 +969,7 @@
|
|
|
969
969
|
return sections.join('\n\n');
|
|
970
970
|
}
|
|
971
971
|
|
|
972
|
-
function buildFallbackReport(input, counts, locale = '
|
|
972
|
+
function buildFallbackReport(input, counts, locale = 'en') {
|
|
973
973
|
const operations = Array.isArray(input.operations) ? input.operations : [];
|
|
974
974
|
const appliedOperations = collectAppliedOperations(input.applyResults);
|
|
975
975
|
const affectedFiles = collectAffectedFiles(operations, input.summary, input.applyResults);
|
|
@@ -1023,7 +1023,7 @@
|
|
|
1023
1023
|
return localized.nextAction || primary.nextAction || '';
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
-
function formatWriteResult(appliedCount, skippedCount, locale = '
|
|
1026
|
+
function formatWriteResult(appliedCount, skippedCount, locale = 'en') {
|
|
1027
1027
|
return textFor(
|
|
1028
1028
|
locale,
|
|
1029
1029
|
`已写入 ${appliedCount} 项,跳过 ${skippedCount} 项`,
|
|
@@ -1031,7 +1031,7 @@
|
|
|
1031
1031
|
);
|
|
1032
1032
|
}
|
|
1033
1033
|
|
|
1034
|
-
function inferUnchangedReason(input, locale = '
|
|
1034
|
+
function inferUnchangedReason(input, locale = 'en') {
|
|
1035
1035
|
if (input.mode === 'ask' || input.status === '只问不改') {
|
|
1036
1036
|
return textFor(locale, '这轮是只问不改。', 'This run was Ask mode.');
|
|
1037
1037
|
}
|
|
@@ -1041,7 +1041,7 @@
|
|
|
1041
1041
|
return '';
|
|
1042
1042
|
}
|
|
1043
1043
|
|
|
1044
|
-
function formatFallbackNextStep(input, skippedCount, affectedFiles, locale = '
|
|
1044
|
+
function formatFallbackNextStep(input, skippedCount, affectedFiles, locale = 'en') {
|
|
1045
1045
|
if (skippedCount) {
|
|
1046
1046
|
return textFor(locale, '请查看本轮报告中的跳过项,处理后可以重试。', 'Review the skipped items in this report, then retry after resolving them.');
|
|
1047
1047
|
}
|
|
@@ -1070,7 +1070,7 @@
|
|
|
1070
1070
|
};
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
|
-
function technicalOnly(event, locale = '
|
|
1073
|
+
function technicalOnly(event, locale = 'en') {
|
|
1074
1074
|
return {
|
|
1075
1075
|
kind: 'technical',
|
|
1076
1076
|
visible: false,
|
|
@@ -1094,7 +1094,7 @@
|
|
|
1094
1094
|
return TECHNICAL_EVENT_PATTERNS.some(pattern => pattern.test(type));
|
|
1095
1095
|
}
|
|
1096
1096
|
|
|
1097
|
-
function summarizeCommandActivity(event, locale = '
|
|
1097
|
+
function summarizeCommandActivity(event, locale = 'en') {
|
|
1098
1098
|
const type = String(event.type || '');
|
|
1099
1099
|
const command = String(event.detail?.command || '');
|
|
1100
1100
|
const output = String(event.detail?.output || '');
|
|
@@ -1140,7 +1140,7 @@
|
|
|
1140
1140
|
return 'check';
|
|
1141
1141
|
}
|
|
1142
1142
|
|
|
1143
|
-
function formatCommandStartedTitle(kind, command, locale = '
|
|
1143
|
+
function formatCommandStartedTitle(kind, command, locale = 'en') {
|
|
1144
1144
|
if (kind === 'search') {
|
|
1145
1145
|
const query = extractSearchQuery(command);
|
|
1146
1146
|
return query ? textFor(locale, `正在搜索项目内容:${query}`, `Searching project content: ${query}`) : textFor(locale, '正在搜索项目内容。', 'Searching project content.');
|
|
@@ -1157,7 +1157,7 @@
|
|
|
1157
1157
|
return textFor(locale, '正在执行一次本地检查。', 'Running a local check.');
|
|
1158
1158
|
}
|
|
1159
1159
|
|
|
1160
|
-
function formatCommandCompletedTitle(kind, output, failed, locale = '
|
|
1160
|
+
function formatCommandCompletedTitle(kind, output, failed, locale = 'en') {
|
|
1161
1161
|
if (failed) {
|
|
1162
1162
|
if (kind === 'search') {
|
|
1163
1163
|
return textFor(locale, '搜索没有正常完成。', 'Search did not finish normally.');
|
|
@@ -1184,7 +1184,7 @@
|
|
|
1184
1184
|
return textFor(locale, '本地检查已完成。', 'Local check completed.');
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
-
function formatCommandPublicDetail(kind, command, locale = '
|
|
1187
|
+
function formatCommandPublicDetail(kind, command, locale = 'en') {
|
|
1188
1188
|
if (kind !== 'search') {
|
|
1189
1189
|
return undefined;
|
|
1190
1190
|
}
|
|
@@ -1235,7 +1235,7 @@
|
|
|
1235
1235
|
return files;
|
|
1236
1236
|
}
|
|
1237
1237
|
|
|
1238
|
-
function formatFilesInline(files = [], locale = '
|
|
1238
|
+
function formatFilesInline(files = [], locale = 'en') {
|
|
1239
1239
|
const values = normalizeStringList(files);
|
|
1240
1240
|
if (!values.length) {
|
|
1241
1241
|
return textFor(locale, '没有文件', 'no files');
|
|
@@ -1300,7 +1300,7 @@
|
|
|
1300
1300
|
.trim();
|
|
1301
1301
|
}
|
|
1302
1302
|
|
|
1303
|
-
function addListSection(sections, label, values, locale = '
|
|
1303
|
+
function addListSection(sections, label, values, locale = 'en') {
|
|
1304
1304
|
const items = normalizeStringList(values);
|
|
1305
1305
|
if (!items.length) {
|
|
1306
1306
|
return;
|
|
@@ -1314,7 +1314,7 @@
|
|
|
1314
1314
|
* rendered report. Per-item first line gets the `- ` bullet; subsequent
|
|
1315
1315
|
* lines pass through verbatim (the formatter already indents them).
|
|
1316
1316
|
*/
|
|
1317
|
-
function addStructuredListSection(sections, label, values, locale = '
|
|
1317
|
+
function addStructuredListSection(sections, label, values, locale = 'en') {
|
|
1318
1318
|
const items = normalizeMultilineStringList(values);
|
|
1319
1319
|
if (!items.length) {
|
|
1320
1320
|
return;
|
|
@@ -1408,7 +1408,7 @@
|
|
|
1408
1408
|
return files;
|
|
1409
1409
|
}
|
|
1410
1410
|
|
|
1411
|
-
function formatOperationLine(operation, locale = '
|
|
1411
|
+
function formatOperationLine(operation, locale = 'en') {
|
|
1412
1412
|
const labels = OPERATION_LABELS[locale] || OPERATION_LABELS.zh;
|
|
1413
1413
|
const label = labels[operation?.type] || operation?.type || textFor(locale, '处理', 'process');
|
|
1414
1414
|
const filePath = operation?.path || operation?.from || operation?.to || textFor(locale, '未知文件', 'unknown file');
|
|
@@ -1418,7 +1418,7 @@
|
|
|
1418
1418
|
: (reason ? `${filePath}:${label}(${reason})` : `${filePath}:${label}`);
|
|
1419
1419
|
}
|
|
1420
1420
|
|
|
1421
|
-
function formatOperationReason(operation, locale = '
|
|
1421
|
+
function formatOperationReason(operation, locale = 'en') {
|
|
1422
1422
|
const key = operation?.reasonKey || '';
|
|
1423
1423
|
const count = Number(operation?.reasonParams?.count || 0);
|
|
1424
1424
|
if (key === 'localWorkspaceDelete') {
|
|
@@ -1440,7 +1440,7 @@
|
|
|
1440
1440
|
return localizeVisibleReason(operation?.reason || '', locale);
|
|
1441
1441
|
}
|
|
1442
1442
|
|
|
1443
|
-
function formatSkippedOperationLine(item, locale = '
|
|
1443
|
+
function formatSkippedOperationLine(item, locale = 'en') {
|
|
1444
1444
|
const operation = item?.operation || {};
|
|
1445
1445
|
const labels = OPERATION_LABELS[locale] || OPERATION_LABELS.zh;
|
|
1446
1446
|
const label = labels[operation.type] || operation.type || textFor(locale, '处理', 'process');
|
|
@@ -1547,7 +1547,7 @@
|
|
|
1547
1547
|
};
|
|
1548
1548
|
}
|
|
1549
1549
|
|
|
1550
|
-
function formatSkippedReason(result = {}, operation = {}, locale = '
|
|
1550
|
+
function formatSkippedReason(result = {}, operation = {}, locale = 'en') {
|
|
1551
1551
|
const key = result.reasonKey || '';
|
|
1552
1552
|
const code = result.code || '';
|
|
1553
1553
|
const filePath = result.reasonParams?.filePath || operation?.path || operation?.from || operation?.to || '';
|
|
@@ -1664,7 +1664,7 @@
|
|
|
1664
1664
|
return parts.join(', ');
|
|
1665
1665
|
}
|
|
1666
1666
|
|
|
1667
|
-
function localizeVisibleReason(reason, locale = '
|
|
1667
|
+
function localizeVisibleReason(reason, locale = 'en') {
|
|
1668
1668
|
const text = cleanVisibleText(reason || '');
|
|
1669
1669
|
if (!text || locale !== 'en') {
|
|
1670
1670
|
return text;
|
|
@@ -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.
|
|
15
|
+
const BUILD_TARGET_VERSION = '2.1.4';
|
|
16
16
|
const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
|
|
17
17
|
const REQUIRED_CAPABILITIES = Object.freeze([
|
|
18
18
|
'bridgePing',
|
|
@@ -1051,6 +1051,9 @@
|
|
|
1051
1051
|
runs,
|
|
1052
1052
|
task: summarizeTextForStorage(session.task, 'task'),
|
|
1053
1053
|
mode: normalizeMode(session.mode || fallbackState.mode),
|
|
1054
|
+
providerId: typeof session.providerId === 'string' && session.providerId
|
|
1055
|
+
? session.providerId
|
|
1056
|
+
: 'builtin',
|
|
1054
1057
|
model: normalizeTextField(session.model || fallbackState.model || DEFAULT_PANEL_STATE.model, 80),
|
|
1055
1058
|
reasoningEffort: normalizeReasoning(session.reasoningEffort || fallbackState.reasoningEffort),
|
|
1056
1059
|
speedTier: normalizeSpeedTier(session.speedTier || fallbackState.speedTier),
|
|
@@ -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);
|
|
@@ -883,6 +889,7 @@ function validateTaskResultOperationQuotas(result = {}) {
|
|
|
883
889
|
}
|
|
884
890
|
|
|
885
891
|
function buildDefaultUserReport(mode, operations = [], params = {}) {
|
|
892
|
+
const locale = normalizeReportLocale(params.locale);
|
|
886
893
|
const checked = (params.project?.files || [])
|
|
887
894
|
.map(file => file?.path)
|
|
888
895
|
.filter(path => typeof path === 'string' && path.length > 0)
|
|
@@ -891,19 +898,29 @@ function buildDefaultUserReport(mode, operations = [], params = {}) {
|
|
|
891
898
|
|
|
892
899
|
return {
|
|
893
900
|
conclusion: hasOperations
|
|
894
|
-
? 'Codex 已准备好建议修改,等待确认或写入。'
|
|
895
|
-
: '这轮任务已完成,没有写入 Overleaf 文件。',
|
|
901
|
+
? reportText(locale, 'Codex prepared proposed changes and is waiting for confirmation or writeback.', 'Codex 已准备好建议修改,等待确认或写入。')
|
|
902
|
+
: reportText(locale, 'This task completed without writing Overleaf files.', '这轮任务已完成,没有写入 Overleaf 文件。'),
|
|
896
903
|
checked,
|
|
897
904
|
findings: [],
|
|
898
|
-
plannedChanges: hasOperations ? operations.map(formatOperationForUserReport) : [],
|
|
905
|
+
plannedChanges: hasOperations ? operations.map(operation => formatOperationForUserReport(operation, locale)) : [],
|
|
899
906
|
appliedChanges: [],
|
|
900
|
-
unchangedReason: hasOperations
|
|
907
|
+
unchangedReason: hasOperations
|
|
908
|
+
? ''
|
|
909
|
+
: (mode === 'ask' ? reportText(locale, 'This run was Ask mode.', '这轮是只问不改。') : ''),
|
|
901
910
|
nextStep: hasOperations
|
|
902
|
-
? '请确认修改方案后写入 Overleaf。'
|
|
903
|
-
: '可以继续追问,或加入更多 @context 后再检查。'
|
|
911
|
+
? reportText(locale, 'Review and confirm the proposed changes before writing them to Overleaf.', '请确认修改方案后写入 Overleaf。')
|
|
912
|
+
: reportText(locale, 'Continue the conversation, or add more @context and run another check.', '可以继续追问,或加入更多 @context 后再检查。')
|
|
904
913
|
};
|
|
905
914
|
}
|
|
906
915
|
|
|
916
|
+
function normalizeReportLocale(locale) {
|
|
917
|
+
return locale === 'zh' ? 'zh' : 'en';
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function reportText(locale, english, chinese) {
|
|
921
|
+
return locale === 'zh' ? chinese : english;
|
|
922
|
+
}
|
|
923
|
+
|
|
907
924
|
function normalizeUserReport(value, fallback) {
|
|
908
925
|
if (!value || typeof value !== 'object') {
|
|
909
926
|
return fallback;
|
|
@@ -926,17 +943,13 @@ function normalizeStringArray(value, fallback = []) {
|
|
|
926
943
|
return value.filter(item => typeof item === 'string');
|
|
927
944
|
}
|
|
928
945
|
|
|
929
|
-
function formatOperationForUserReport(operation) {
|
|
930
|
-
const labels =
|
|
931
|
-
edit: '编辑',
|
|
932
|
-
create: '
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
};
|
|
937
|
-
const label = labels[operation?.type] || operation?.type || '处理';
|
|
938
|
-
const filePath = operation?.path || operation?.to || '未知文件';
|
|
939
|
-
return `${filePath}:${label}`;
|
|
946
|
+
function formatOperationForUserReport(operation, locale = 'en') {
|
|
947
|
+
const labels = locale === 'zh'
|
|
948
|
+
? { edit: '编辑', create: '新建', rename: '重命名', move: '移动', delete: '删除' }
|
|
949
|
+
: { edit: 'edit', create: 'create', rename: 'rename', move: 'move', delete: 'delete' };
|
|
950
|
+
const label = labels[operation?.type] || operation?.type || reportText(locale, 'change', '处理');
|
|
951
|
+
const filePath = operation?.path || operation?.to || reportText(locale, 'unknown file', '未知文件');
|
|
952
|
+
return locale === 'zh' ? `${filePath}:${label}` : `${filePath}: ${label}`;
|
|
940
953
|
}
|
|
941
954
|
|
|
942
955
|
function collectResultOperations(result) {
|