codex-overleaf-link 1.6.1 → 1.6.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 +23 -21
- package/extension/src/shared/agentTranscript.js +2 -2
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/i18n.js +40 -0
- package/native-host/src/codexSessionRunner.js +2 -1
- package/native-host/src/skills/parallel-subagents/SKILL.md +7 -0
- package/native-host/src/subagentBroker.js +65 -3
- 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-1.6.
|
|
6
|
+
<img src="https://img.shields.io/badge/version-1.6.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 native host **and** sets up the extension: the script r
|
|
|
38
38
|
macOS / Linux:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
CODEX_OVERLEAF_REF=v1.6.
|
|
41
|
+
CODEX_OVERLEAF_REF=v1.6.3 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.6.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/v1.6.
|
|
48
|
-
$env:CODEX_OVERLEAF_REF='v1.6.
|
|
47
|
+
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.6.3/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v1.6.3'
|
|
49
49
|
powershell -ExecutionPolicy Bypass -File install.ps1
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -56,10 +56,10 @@ Then, in the `chrome://extensions` tab the script opened: enable **Developer mod
|
|
|
56
56
|
`npm exec` installs and updates the **native host only** — it does not include the Chrome extension. Use it if you prefer a pinned npm package to a source checkout.
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
npm exec --yes codex-overleaf-link@1.6.
|
|
59
|
+
npm exec --yes codex-overleaf-link@1.6.3 -- install-native
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Then add the extension yourself: download `codex-overleaf-link-extension-v1.6.
|
|
62
|
+
Then add the extension yourself: download `codex-overleaf-link-extension-v1.6.3.zip` from the [v1.6.3 GitHub Release](https://github.com/Ghqqqq/codex-overleaf-link/releases/tag/v1.6.3), unzip it to a stable folder, and in `chrome://extensions` enable **Developer mode**, click **Load unpacked**, and select that folder.
|
|
63
63
|
|
|
64
64
|
### Open Overleaf
|
|
65
65
|
|
|
@@ -86,9 +86,9 @@ npm installs, updates, uninstalls, and diagnoses the native host only. npm does
|
|
|
86
86
|
|
|
87
87
|
| Action | Command |
|
|
88
88
|
|--------|---------|
|
|
89
|
-
| Install / update | `npm exec --yes codex-overleaf-link@1.6.
|
|
90
|
-
| Diagnose | `npm exec --yes codex-overleaf-link@1.6.
|
|
91
|
-
| Uninstall | `npm exec --yes codex-overleaf-link@1.6.
|
|
89
|
+
| Install / update | `npm exec --yes codex-overleaf-link@1.6.3 -- install-native` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@1.6.3 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@1.6.3 -- uninstall-native` |
|
|
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 @@ To update, re-run any of the [native host installers](#install) — they install
|
|
|
98
98
|
|
|
99
99
|
## GitHub Release Artifacts
|
|
100
100
|
|
|
101
|
-
The v1.6.
|
|
101
|
+
The v1.6.3 GitHub Release contains:
|
|
102
102
|
|
|
103
|
-
- `codex-overleaf-link-extension-v1.6.
|
|
104
|
-
- `codex-overleaf-native-host-v1.6.
|
|
105
|
-
- `codex-overleaf-link-1.6.
|
|
106
|
-
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v1.6.
|
|
107
|
-
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.6.
|
|
103
|
+
- `codex-overleaf-link-extension-v1.6.3.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v1.6.3.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-1.6.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 `v1.6.3` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.6.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 v1.6.1 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@1.6.
|
|
118
|
+
npm exec --yes codex-overleaf-link@1.6.3 -- uninstall-native
|
|
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=v1.6.
|
|
153
|
+
CODEX_OVERLEAF_REF=v1.6.3 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.6.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@1.6.
|
|
159
|
+
npm exec --yes codex-overleaf-link@1.6.3 -- uninstall-native --browser chromium
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
## Features
|
|
@@ -172,6 +172,7 @@ npm exec --yes codex-overleaf-link@1.6.1 -- uninstall-native --browser chromium
|
|
|
172
172
|
- **@ context** — attach specific files, `@compile-log`, or `@current-section` to the prompt.
|
|
173
173
|
- **Composer attachments and binary writeback** — paste or drop PDFs, images, and files into the composer as turn-scoped Codex context, and review Codex-created assets before creating or replacing them in Overleaf.
|
|
174
174
|
- **Codex Overleaf skills** — install reusable plugin-scoped skills through the slash menu, then let Codex auto-trigger them or select one explicitly for the next turn. Each skill has its own enable toggle, honored at run time.
|
|
175
|
+
- **Parallel subagents (experimental)** — enable the `parallel-subagents` skill and Codex can fan a decomposable task (e.g. polish several sections) out to real parallel Codex workers that the native host runs for you. Workers own disjoint files; a single file is parallelized by slicing its sections (scatter–gather) or by serialized scoped jobs, so concurrent edits never clobber each other. Each subagent's progress streams into the timeline, and edits a worker was not assigned are withheld from writeback.
|
|
175
176
|
- **Governance rules** — configure project read-only and writable path rules that block unsafe writeback before browser mutation.
|
|
176
177
|
- **Sensitive preflight** — scan selected project context for likely secrets before sending it to Codex.
|
|
177
178
|
- **Audit and diagnostics** — keep local run records and export redacted diagnostic bundles for issue reports.
|
|
@@ -185,6 +186,7 @@ npm exec --yes codex-overleaf-link@1.6.1 -- uninstall-native --browser chromium
|
|
|
185
186
|
- **Fix a compile error** — choose Suggest mode, attach `@compile-log`, ask Codex to diagnose and patch the failing file, review the diff, apply it, then recompile from the panel.
|
|
186
187
|
- **Rewrite a paragraph** — select the target file or `@current-section`, ask for a tone or clarity rewrite in Suggest mode, review the text diff, and accept only the hunks you want.
|
|
187
188
|
- **Translate a section** — attach the source section with `@file` or `@current-section`, specify the target language and terminology constraints, then review the proposed replacement before writeback.
|
|
189
|
+
- **Polish several sections at once** — enable the `parallel-subagents` skill, then ask Codex to polish multiple chapters or sections in parallel; it splits the work across subagents, runs them concurrently, and merges the results back for a single review.
|
|
188
190
|
|
|
189
191
|
## How It Works
|
|
190
192
|
|
|
@@ -289,7 +291,7 @@ Composer attachments are turn-scoped Codex context. Limits are 8 attachments per
|
|
|
289
291
|
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.
|
|
290
292
|
|
|
291
293
|
```bash
|
|
292
|
-
npm exec --yes codex-overleaf-link@1.6.
|
|
294
|
+
npm exec --yes codex-overleaf-link@1.6.3 -- install-native
|
|
293
295
|
```
|
|
294
296
|
|
|
295
297
|
**The Windows popup or panel shows a Bash recovery command**
|
|
@@ -338,8 +340,8 @@ Use this matrix for release-candidate signoff and compatibility reports. Record
|
|
|
338
340
|
| Browser/channel/version | Google Chrome channel and version. | Google Chrome channel and version. | Google Chrome channel and version. | Chromium channel/package and version. |
|
|
339
341
|
| 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`. |
|
|
340
342
|
| 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`. |
|
|
341
|
-
| Installer/update command | `npm exec --yes codex-overleaf-link@1.6.
|
|
342
|
-
| Uninstall command | `npm exec --yes codex-overleaf-link@1.6.
|
|
343
|
+
| Installer/update command | `npm exec --yes codex-overleaf-link@1.6.3 -- install-native` | `npm exec --yes codex-overleaf-link@1.6.3 -- install-native` | `npm exec --yes codex-overleaf-link@1.6.3 -- install-native` | `npm exec --yes codex-overleaf-link@1.6.3 -- install-native --browser chromium` |
|
|
344
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@1.6.3 -- uninstall-native` | `npm exec --yes codex-overleaf-link@1.6.3 -- uninstall-native` | `npm exec --yes codex-overleaf-link@1.6.3 -- uninstall-native` | `npm exec --yes codex-overleaf-link@1.6.3 -- uninstall-native --browser chromium` |
|
|
343
345
|
| 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` |
|
|
344
346
|
| 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`. |
|
|
345
347
|
| 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. |
|
|
@@ -268,14 +268,14 @@
|
|
|
268
268
|
return {
|
|
269
269
|
...base,
|
|
270
270
|
status: 'warning',
|
|
271
|
-
title: textFor(locale, `⚠
|
|
271
|
+
title: textFor(locale, `⚠ 子代理改动了未分配给它的文件 ${label},该改动已丢弃、未写回 Overleaf。如果该文件确实需要修改,请重新运行。`, `⚠ A subagent edited ${label}, which it was not assigned; that change was discarded and not written to Overleaf. Re-run if that file should be edited.`)
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
274
|
if (type === 'codex.subagent.drained') {
|
|
275
275
|
return {
|
|
276
276
|
...base,
|
|
277
277
|
status: 'completed',
|
|
278
|
-
title: textFor(locale, '↳
|
|
278
|
+
title: textFor(locale, '↳ 子代理已全部完成。', '↳ All subagents finished.')
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
281
|
return { ...base, status: event.status || 'running', title: label };
|
|
@@ -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 = '1.6.
|
|
15
|
+
const BUILD_TARGET_VERSION = '1.6.3';
|
|
16
16
|
const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
|
|
17
17
|
const REQUIRED_CAPABILITIES = Object.freeze([
|
|
18
18
|
'bridgePing',
|
|
@@ -272,6 +272,8 @@
|
|
|
272
272
|
modeAuto: 'Auto',
|
|
273
273
|
modeAutoTitle: 'Write directly after authorization. Deletes still require confirmation.',
|
|
274
274
|
addContext: 'Add @ context',
|
|
275
|
+
reasoningLabel: 'Reasoning effort',
|
|
276
|
+
speedLabel: 'Speed',
|
|
275
277
|
requireReviewing: 'Track',
|
|
276
278
|
requireReviewingTitle: 'When enabled, Codex checks or switches Overleaf Reviewing/Track Changes before writing. Deletes still require confirmation.',
|
|
277
279
|
autoCompile: 'Compile',
|
|
@@ -347,6 +349,24 @@
|
|
|
347
349
|
failureReason_section_next: 'Next',
|
|
348
350
|
// FailureReason bilingual high-priority strings (design spec §15.4).
|
|
349
351
|
// Each entry follows the §9 catalog copy. {file} / {activeFile} interpolate from the failure record.
|
|
352
|
+
failureReason_partial_write_needs_review_user: 'Some operations wrote to Overleaf; others were skipped.',
|
|
353
|
+
failureReason_partial_write_needs_review_next: 'Review the written files; use "Undo written parts" to roll back if needed.',
|
|
354
|
+
failureReason_codex_run_cancelled_user: 'The local Codex run was cancelled.',
|
|
355
|
+
failureReason_codex_run_cancelled_next: 'Start a new run when you are ready.',
|
|
356
|
+
failureReason_write_operation_failed_user: 'The editor write call for {file} failed.',
|
|
357
|
+
failureReason_write_operation_failed_next: 'Retry once the Overleaf editor is stable.',
|
|
358
|
+
failureReason_write_timeout_user: 'Overleaf did not accept the write to {file} before timeout.',
|
|
359
|
+
failureReason_write_timeout_next: 'Refresh Overleaf, then retry.',
|
|
360
|
+
failureReason_undo_operation_failed_user: 'The Overleaf undo or reject operation failed.',
|
|
361
|
+
failureReason_undo_operation_failed_next: 'Use Overleaf undo/review tools manually.',
|
|
362
|
+
failureReason_undo_partial_user: "Some of this run's writes were undone; others were skipped.",
|
|
363
|
+
failureReason_undo_partial_next: 'Review the remaining files and retry undo if it is safe.',
|
|
364
|
+
failureReason_accept_force_editing_failed_user: 'Codex could not enter a stable Editing mode to accept the changes.',
|
|
365
|
+
failureReason_accept_force_editing_failed_next: 'Switch Overleaf to Editing manually, then retry.',
|
|
366
|
+
failureReason_accept_replay_failed_user: 'Replaying the accepted content into {file} failed.',
|
|
367
|
+
failureReason_accept_replay_failed_next: 'Inspect the file in Overleaf, then retry.',
|
|
368
|
+
failureReason_native_request_failed_user: 'The request to the local Codex bridge failed.',
|
|
369
|
+
failureReason_native_request_failed_next: 'Open Diagnostics to check the bridge, then retry.',
|
|
350
370
|
failureReason_project_snapshot_unavailable_user: 'Codex could not read the Overleaf project snapshot.',
|
|
351
371
|
failureReason_project_snapshot_unavailable_next: 'Refresh Overleaf, then rerun the task.',
|
|
352
372
|
failureReason_selected_context_unresolved_user: 'Codex could not resolve the requested selection or context.',
|
|
@@ -680,6 +700,8 @@
|
|
|
680
700
|
modeAuto: '自动写入',
|
|
681
701
|
modeAutoTitle: '授权后直接写入,删除仍需确认',
|
|
682
702
|
addContext: '添加 @ 上下文',
|
|
703
|
+
reasoningLabel: '推理强度',
|
|
704
|
+
speedLabel: '速度',
|
|
683
705
|
requireReviewing: '留痕',
|
|
684
706
|
requireReviewingTitle: '开启后,写入前会确认并尝试切到 Overleaf Reviewing/Track Changes;删除仍需确认。',
|
|
685
707
|
autoCompile: '编译',
|
|
@@ -754,6 +776,24 @@
|
|
|
754
776
|
failureReason_section_code: '代码',
|
|
755
777
|
failureReason_section_next: '下一步',
|
|
756
778
|
// FailureReason 高优先级双语文案(设计规格 §15.4)。文案对应 §9 目录的英文 fallback。
|
|
779
|
+
failureReason_partial_write_needs_review_user: '部分操作已写入 Overleaf,其余被跳过。',
|
|
780
|
+
failureReason_partial_write_needs_review_next: '请检查已写入的文件;如需回滚,使用「撤销已写入部分」。',
|
|
781
|
+
failureReason_codex_run_cancelled_user: '本地 Codex 任务已取消。',
|
|
782
|
+
failureReason_codex_run_cancelled_next: '准备好后可以重新发起一轮任务。',
|
|
783
|
+
failureReason_write_operation_failed_user: '对 {file} 的编辑器写入调用失败。',
|
|
784
|
+
failureReason_write_operation_failed_next: '等 Overleaf 编辑器稳定后重试。',
|
|
785
|
+
failureReason_write_timeout_user: 'Overleaf 在超时前没有接受对 {file} 的写入。',
|
|
786
|
+
failureReason_write_timeout_next: '刷新 Overleaf 后重试。',
|
|
787
|
+
failureReason_undo_operation_failed_user: 'Overleaf 的撤销或拒绝操作失败。',
|
|
788
|
+
failureReason_undo_operation_failed_next: '请手动使用 Overleaf 的撤销/审阅工具。',
|
|
789
|
+
failureReason_undo_partial_user: '本轮的部分写入已撤销,其余被跳过。',
|
|
790
|
+
failureReason_undo_partial_next: '检查剩余文件,确认安全后再重试撤销。',
|
|
791
|
+
failureReason_accept_force_editing_failed_user: 'Codex 未能进入稳定的 Editing 模式来接受改动。',
|
|
792
|
+
failureReason_accept_force_editing_failed_next: '请手动把 Overleaf 切到 Editing,然后重试。',
|
|
793
|
+
failureReason_accept_replay_failed_user: '把已接受的内容回放到 {file} 时失败。',
|
|
794
|
+
failureReason_accept_replay_failed_next: '请在 Overleaf 中检查该文件后重试。',
|
|
795
|
+
failureReason_native_request_failed_user: '向本地 Codex bridge 的请求失败。',
|
|
796
|
+
failureReason_native_request_failed_next: '打开「诊断」检查 bridge 后重试。',
|
|
757
797
|
failureReason_project_snapshot_unavailable_user: 'Codex 没能读到 Overleaf 项目快照。',
|
|
758
798
|
failureReason_project_snapshot_unavailable_next: '请刷新 Overleaf,然后重试本轮任务。',
|
|
759
799
|
failureReason_selected_context_unresolved_user: 'Codex 没能解析所选的内容或上下文。',
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { spawn } = require('node:child_process');
|
|
4
4
|
const fs = require('node:fs');
|
|
5
5
|
const path = require('node:path');
|
|
6
|
+
const { version: PACKAGE_VERSION } = require('../../package.json');
|
|
6
7
|
const { SUBAGENT_QUEUE_DIR, collectMirrorChangesDetailed, getProjectMirror, markMirrorDirty, syncOverleafToMirror } = require('./mirrorWorkspace');
|
|
7
8
|
const { computeLineDiff } = require('./diffEngine');
|
|
8
9
|
const { computeTextPatches } = require('./textPatch');
|
|
@@ -854,7 +855,7 @@ function runCodexAppServerSession(input) {
|
|
|
854
855
|
await request('initialize', {
|
|
855
856
|
clientInfo: {
|
|
856
857
|
name: 'codex-overleaf-link',
|
|
857
|
-
version:
|
|
858
|
+
version: PACKAGE_VERSION
|
|
858
859
|
},
|
|
859
860
|
capabilities: null
|
|
860
861
|
});
|
|
@@ -78,12 +78,19 @@ Rules:
|
|
|
78
78
|
## 4. Poll for results
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
|
+
tries=0
|
|
81
82
|
while [ "$(ls .codex-overleaf-subagents/results/*.json 2>/dev/null | wc -l)" -lt <jobCount> ]; do
|
|
82
83
|
sleep 10
|
|
84
|
+
tries=$((tries + 1))
|
|
85
|
+
if [ "$tries" -ge 60 ]; then break; fi # ~10 min cap: never poll forever
|
|
83
86
|
ls .codex-overleaf-subagents/results/ 2>/dev/null
|
|
84
87
|
done
|
|
85
88
|
```
|
|
86
89
|
|
|
90
|
+
If the loop hits the cap, a result never arrived (e.g. a lost or duplicate
|
|
91
|
+
`id`). Do not keep waiting: read whatever results exist and finish the
|
|
92
|
+
remaining slices yourself inline.
|
|
93
|
+
|
|
87
94
|
Then read each `results/<id>.json` (`status`: completed | failed | rejected |
|
|
88
95
|
timeout | cancelled; `summary`; `changedFiles`) and, when you need the full
|
|
89
96
|
close-out, `results/<id>.last-message.md`.
|
|
@@ -269,7 +269,21 @@ function createSubagentBroker(options = {}) {
|
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
const [jobId] = queued.splice(index, 1);
|
|
272
|
-
|
|
272
|
+
const entry = jobs.get(jobId);
|
|
273
|
+
try {
|
|
274
|
+
startWorker(entry);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
// A job is spliced out of `queued` before it starts; if startWorker
|
|
277
|
+
// throws it would vanish with no result, hanging a lead still polling
|
|
278
|
+
// for its count. Emit a failed result so the poll loop can proceed.
|
|
279
|
+
if (entry) {
|
|
280
|
+
entry.status = 'failed';
|
|
281
|
+
}
|
|
282
|
+
appendLog(jobId, `start_failed: ${error?.stack || error?.message || String(error)}`);
|
|
283
|
+
try {
|
|
284
|
+
writeResult({ id: jobId, status: 'failed', reason: error?.message || 'subagent failed to start' });
|
|
285
|
+
} catch (_writeError) { /* result dir may be gone */ }
|
|
286
|
+
}
|
|
273
287
|
}
|
|
274
288
|
}
|
|
275
289
|
|
|
@@ -340,6 +354,17 @@ function createSubagentBroker(options = {}) {
|
|
|
340
354
|
entry.status = resultFields.status;
|
|
341
355
|
const ownedAfter = hashPaths(job.files);
|
|
342
356
|
const changedFiles = job.files.filter(file => entry.ownedBefore.get(file) !== ownedAfter.get(file));
|
|
357
|
+
if (resultFields.status !== 'completed' && changedFiles.length) {
|
|
358
|
+
// A worker that did not finish cleanly (timeout / cancelled / failed)
|
|
359
|
+
// may have left a half-written file on disk. The mirror scan would
|
|
360
|
+
// otherwise ship that partial edit straight to Overleaf, so withhold it
|
|
361
|
+
// the same way ownership violations are withheld — the runner's S8
|
|
362
|
+
// demotion reads getViolationPaths() and drops these from writeback
|
|
363
|
+
// (spec S8 safety extension, v1.6.2).
|
|
364
|
+
for (const file of changedFiles) {
|
|
365
|
+
violationPaths.add(file);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
343
368
|
const result = {
|
|
344
369
|
id: job.id,
|
|
345
370
|
...resultFields,
|
|
@@ -495,19 +520,39 @@ function createSubagentBroker(options = {}) {
|
|
|
495
520
|
|
|
496
521
|
async function stop({ drain = true } = {}) {
|
|
497
522
|
accepting = false;
|
|
523
|
+
// Queued-but-unstarted jobs would otherwise vanish with no result file,
|
|
524
|
+
// hanging a lead still polling for its job count. Settle them first
|
|
525
|
+
// (mirrors onParentAbort's queue handling).
|
|
526
|
+
for (const jobId of queued.splice(0)) {
|
|
527
|
+
const entry = jobs.get(jobId);
|
|
528
|
+
if (entry) {
|
|
529
|
+
entry.status = 'cancelled';
|
|
530
|
+
}
|
|
531
|
+
writeResult({ id: jobId, status: 'cancelled', reason: 'The run ended before this subagent started.' });
|
|
532
|
+
}
|
|
498
533
|
if (drain && running.size) {
|
|
534
|
+
let graceTimer = null;
|
|
499
535
|
const grace = new Promise(resolve => {
|
|
500
|
-
setTimeout(resolve, limits.drainGraceMs);
|
|
536
|
+
graceTimer = setTimeout(resolve, limits.drainGraceMs);
|
|
501
537
|
});
|
|
502
538
|
await Promise.race([
|
|
503
539
|
Promise.allSettled([...running.values()].map(worker => worker.promise)),
|
|
504
540
|
grace
|
|
505
541
|
]);
|
|
542
|
+
// The grace timer gates an awaited race; if the workers settled first it
|
|
543
|
+
// must be cleared or it keeps the event loop alive for drainGraceMs
|
|
544
|
+
// (the "keep timers gated, then clear" discipline from c3cd357).
|
|
545
|
+
if (graceTimer) {
|
|
546
|
+
clearTimeout(graceTimer);
|
|
547
|
+
}
|
|
506
548
|
}
|
|
507
549
|
for (const { controller } of running.values()) {
|
|
508
550
|
controller.abort(new Error('broker drained'));
|
|
509
551
|
}
|
|
510
|
-
|
|
552
|
+
// Bounded final settle: a worker that ignores its abort must not hang
|
|
553
|
+
// stop() forever — that strands codex.run and leaks the project lock (the
|
|
554
|
+
// very zombie-lock case handleCodexCancel exists to recover from).
|
|
555
|
+
await settleRunningWithin(limits.drainGraceMs);
|
|
511
556
|
if (jobs.size) {
|
|
512
557
|
emit('codex.subagent.drained', 'subagents drained', {
|
|
513
558
|
jobs: jobs.size,
|
|
@@ -517,6 +562,23 @@ function createSubagentBroker(options = {}) {
|
|
|
517
562
|
close();
|
|
518
563
|
}
|
|
519
564
|
|
|
565
|
+
async function settleRunningWithin(timeoutMs) {
|
|
566
|
+
if (!running.size) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
let timer = null;
|
|
570
|
+
const fallback = new Promise(resolve => {
|
|
571
|
+
timer = setTimeout(resolve, Math.max(0, timeoutMs));
|
|
572
|
+
});
|
|
573
|
+
await Promise.race([
|
|
574
|
+
Promise.allSettled([...running.values()].map(worker => worker.promise)),
|
|
575
|
+
fallback
|
|
576
|
+
]);
|
|
577
|
+
if (timer) {
|
|
578
|
+
clearTimeout(timer);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
520
582
|
function close() {
|
|
521
583
|
if (closed) {
|
|
522
584
|
return;
|