codex-overleaf-link 1.6.0 → 1.6.2
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/skills/parallel-subagents/SKILL.md +71 -15
- package/native-host/src/subagentBroker.js +96 -14
- 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.2-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.2 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.6.2/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.2/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v1.6.2'
|
|
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.2 -- 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.2.zip` from the [v1.6.2 GitHub Release](https://github.com/Ghqqqq/codex-overleaf-link/releases/tag/v1.6.2), 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.2 -- install-native` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@1.6.2 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@1.6.2 -- 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.2 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.2.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v1.6.2.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-1.6.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 `v1.6.2` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.6.2` 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.0 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.2 -- 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.2 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.6.2/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.2 -- uninstall-native --browser chromium
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
## Features
|
|
@@ -172,6 +172,7 @@ npm exec --yes codex-overleaf-link@1.6.0 -- 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.0 -- 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.2 -- 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.2 -- install-native` | `npm exec --yes codex-overleaf-link@1.6.2 -- install-native` | `npm exec --yes codex-overleaf-link@1.6.2 -- install-native` | `npm exec --yes codex-overleaf-link@1.6.2 -- install-native --browser chromium` |
|
|
344
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@1.6.2 -- uninstall-native` | `npm exec --yes codex-overleaf-link@1.6.2 -- uninstall-native` | `npm exec --yes codex-overleaf-link@1.6.2 -- uninstall-native` | `npm exec --yes codex-overleaf-link@1.6.2 -- 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.2';
|
|
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 没能解析所选的内容或上下文。',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: parallel-subagents
|
|
3
3
|
description: >
|
|
4
|
-
When a task decomposes into independent
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
When a task decomposes into independent slices — separate files, OR
|
|
5
|
+
separate sections of ONE file — fan it out: write job files to the subagent
|
|
6
|
+
queue and the host runs real parallel Codex workers for you. For a single
|
|
7
|
+
file, extract per-section slice files into the queue's work/ zone, let
|
|
8
|
+
workers polish them in parallel, then reassemble (scatter-gather). Every
|
|
9
|
+
job must state an explicit, non-overlapping scope.
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
# Parallel Subagents
|
|
@@ -18,18 +19,26 @@ Codex agent confined to the files you assign it.
|
|
|
18
19
|
## 1. When to use
|
|
19
20
|
|
|
20
21
|
Use this when ALL of these hold:
|
|
21
|
-
- The task splits into ≥ 2 independent slices
|
|
22
|
-
|
|
22
|
+
- The task splits into ≥ 2 independent slices: different **files**, or
|
|
23
|
+
different **sections of one file** (use the scatter-gather workflow in §5).
|
|
23
24
|
- Slices do not depend on each other's output.
|
|
24
25
|
- Each slice is small enough to finish in a few minutes.
|
|
25
26
|
|
|
26
27
|
Do NOT use it (work sequentially yourself instead) when:
|
|
27
|
-
- The project keeps everything in one monolithic file — never split one file
|
|
28
|
-
across jobs.
|
|
29
28
|
- Slices are deeply cross-referenced and must be edited together.
|
|
30
29
|
- There are fewer than 2 real slices.
|
|
31
30
|
- The handshake file below is missing or not `ready`.
|
|
32
31
|
|
|
32
|
+
## 1b. Explicit scope — the iron rule
|
|
33
|
+
|
|
34
|
+
Every job's `task` MUST state its exact working scope, and scopes MUST NOT
|
|
35
|
+
overlap:
|
|
36
|
+
- multi-file job: name the file(s) and what inside them is in scope;
|
|
37
|
+
- single-file slice job: name the section (`\section{...}` title) and quote
|
|
38
|
+
the slice's exact first and last source lines.
|
|
39
|
+
Never write two jobs whose scopes could touch the same text. If you cannot
|
|
40
|
+
state a slice's boundaries precisely, do that slice yourself instead.
|
|
41
|
+
|
|
33
42
|
## 2. Handshake
|
|
34
43
|
|
|
35
44
|
Read `.codex-overleaf-subagents/broker.json`. If it is missing or its
|
|
@@ -60,40 +69,87 @@ Rules:
|
|
|
60
69
|
- `id`: lowercase letters/digits/hyphens, ≤ 32 chars, unique.
|
|
61
70
|
- `task`: complete, self-contained instructions — workers cannot ask
|
|
62
71
|
questions. Repeat shared style guidance in EVERY job.
|
|
63
|
-
- `files`: workspace-relative paths the job may edit
|
|
64
|
-
|
|
72
|
+
- `files`: workspace-relative paths the job may edit — project files or
|
|
73
|
+
slice files under `.codex-overleaf-subagents/work/`. Jobs that share a
|
|
74
|
+
file are admitted but run ONE AT A TIME (the broker serializes them);
|
|
75
|
+
disjoint jobs run in parallel.
|
|
65
76
|
- `readOnlyContext`: files the worker may read but must not edit.
|
|
66
77
|
|
|
67
78
|
## 4. Poll for results
|
|
68
79
|
|
|
69
80
|
```bash
|
|
81
|
+
tries=0
|
|
70
82
|
while [ "$(ls .codex-overleaf-subagents/results/*.json 2>/dev/null | wc -l)" -lt <jobCount> ]; do
|
|
71
83
|
sleep 10
|
|
84
|
+
tries=$((tries + 1))
|
|
85
|
+
if [ "$tries" -ge 60 ]; then break; fi # ~10 min cap: never poll forever
|
|
72
86
|
ls .codex-overleaf-subagents/results/ 2>/dev/null
|
|
73
87
|
done
|
|
74
88
|
```
|
|
75
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
|
+
|
|
76
94
|
Then read each `results/<id>.json` (`status`: completed | failed | rejected |
|
|
77
95
|
timeout | cancelled; `summary`; `changedFiles`) and, when you need the full
|
|
78
96
|
close-out, `results/<id>.last-message.md`.
|
|
79
97
|
|
|
80
|
-
## 5.
|
|
98
|
+
## 5. Single file? Two safe modes
|
|
99
|
+
|
|
100
|
+
Two workers must NEVER edit the same file at the same moment (whole-file
|
|
101
|
+
writes race and silently drop each other's edits) — the broker guarantees
|
|
102
|
+
this for you. Pick per task:
|
|
103
|
+
|
|
104
|
+
**Mode A — serialized scoped jobs (simple, no slicing).** Just write one job
|
|
105
|
+
per section, all owning the same file, each `task` stating its exact section
|
|
106
|
+
scope (iron rule §1b). The broker runs them one at a time, each seeing the
|
|
107
|
+
previous job's output. No parallel speedup within that file (jobs on OTHER
|
|
108
|
+
files still run alongside), but zero assembly work. Prefer this for 2-3
|
|
109
|
+
sections or quick passes.
|
|
110
|
+
|
|
111
|
+
**Mode B — scatter-gather slices (true parallelism).** For a big file where
|
|
112
|
+
wall-clock matters, give each worker its own physical slice:
|
|
113
|
+
|
|
114
|
+
1. **Scatter** — for each independent section, copy its EXACT text (from its
|
|
115
|
+
`\section{...}` line up to, not including, the next `\section`) into a
|
|
116
|
+
slice file, verbatim, atomically:
|
|
117
|
+
`cat > .codex-overleaf-subagents/work/.tmp-sec2 <<'EOF' ... EOF` then
|
|
118
|
+
`mv .codex-overleaf-subagents/work/.tmp-sec2 .codex-overleaf-subagents/work/sec2.tex`.
|
|
119
|
+
Preamble, frontmatter, and anything you cannot bound precisely stays with
|
|
120
|
+
you.
|
|
121
|
+
2. **Jobs** — one per slice. `files` = that slice file only. The `task` must
|
|
122
|
+
say: this is a fragment of `<original file>` covering section `<title>`
|
|
123
|
+
(quote first + last line); polish it IN PLACE; do not add a preamble or
|
|
124
|
+
document wrapper; keep the project's edit conventions (e.g.
|
|
125
|
+
annotated-rewrite). Put the original file in `readOnlyContext` so the
|
|
126
|
+
worker sees surrounding context.
|
|
127
|
+
3. **Gather** — after all results: verify each slice still starts with its
|
|
128
|
+
`\section{...}` line, then replace the corresponding original block in
|
|
129
|
+
the source file with the slice content, one section at a time, yourself.
|
|
130
|
+
If a slice lost its boundary line, treat that slice as failed and redo it
|
|
131
|
+
inline.
|
|
132
|
+
|
|
133
|
+
Slice files live inside the queue zone, so they are scratch: they never sync
|
|
134
|
+
to Overleaf — only your reassembled edits to the real file do.
|
|
135
|
+
|
|
136
|
+
## 6. Wave discipline (important)
|
|
81
137
|
|
|
82
138
|
While any job is queued or running, do **not** edit project files yourself —
|
|
83
139
|
write jobs, poll, wait. Do your own edits before the first job or after the
|
|
84
140
|
last result. Files changed during a wave that no job owns are reported as
|
|
85
141
|
ownership violations and **excluded from the Overleaf writeback**.
|
|
86
142
|
|
|
87
|
-
##
|
|
143
|
+
## 7. Integrate
|
|
88
144
|
|
|
89
145
|
- For each `completed` job: read its summary, spot-check the owned files, and
|
|
90
146
|
smooth terminology/transitions ACROSS slice boundaries yourself.
|
|
91
147
|
- For each `failed` / `timeout` / `rejected` job: do that slice inline
|
|
92
|
-
yourself now (check `reason
|
|
148
|
+
yourself now (check `reason`).
|
|
93
149
|
- Mention any violations in your close-out so the user knows those edits were
|
|
94
150
|
withheld from writeback.
|
|
95
151
|
|
|
96
|
-
##
|
|
152
|
+
## 8. Close out
|
|
97
153
|
|
|
98
154
|
End with a per-slice one-liner (job → what changed) plus an overall summary.
|
|
99
155
|
This becomes the run report the user reads.
|
|
@@ -76,6 +76,7 @@ function createSubagentBroker(options = {}) {
|
|
|
76
76
|
fs.mkdirSync(jobsDir, { recursive: true });
|
|
77
77
|
fs.mkdirSync(resultsDir, { recursive: true });
|
|
78
78
|
fs.mkdirSync(logsDir, { recursive: true });
|
|
79
|
+
fs.mkdirSync(path.join(queueRoot, 'work'), { recursive: true });
|
|
79
80
|
startedAt = Date.now();
|
|
80
81
|
accepting = true;
|
|
81
82
|
writeBrokerFile('ready');
|
|
@@ -194,15 +195,10 @@ function createSubagentBroker(options = {}) {
|
|
|
194
195
|
}
|
|
195
196
|
owned.push(safe);
|
|
196
197
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const overlap = entry.job.files.find(file => owned.includes(file));
|
|
202
|
-
if (overlap) {
|
|
203
|
-
return { reason: 'file_conflict', path: overlap, conflictsWith: otherId };
|
|
204
|
-
}
|
|
205
|
-
}
|
|
198
|
+
// Overlapping ownership no longer rejects: same-file jobs are admitted
|
|
199
|
+
// and SERIALIZED by the scheduler (fillSlots never runs two jobs whose
|
|
200
|
+
// files intersect). Prompt-scoped same-file delegation is then safe —
|
|
201
|
+
// the physical lost-update race only exists under concurrency (v1.6.1).
|
|
206
202
|
// Wave-aware admission: the parent turn has no default absolute deadline,
|
|
207
203
|
// so the broker enforces its own wall-clock envelope across ALL waves.
|
|
208
204
|
const projectedWaves = Math.ceil((queued.length + running.size + 1) / limits.maxWorkers);
|
|
@@ -229,6 +225,13 @@ function createSubagentBroker(options = {}) {
|
|
|
229
225
|
return null;
|
|
230
226
|
}
|
|
231
227
|
if (segments[0] === SUBAGENT_QUEUE_DIR) {
|
|
228
|
+
// The queue control plane (jobs/results/logs/broker.json) is never
|
|
229
|
+
// ownable — but the work/ scratch zone IS: single-file fan-out slices
|
|
230
|
+
// live there (v1.6.1 scatter-gather), excluded from writeback by the
|
|
231
|
+
// mirror-scan rule yet fully owned/hashed like any other job file.
|
|
232
|
+
if (segments[1] === 'work' && segments.length >= 3) {
|
|
233
|
+
return segments.join('/');
|
|
234
|
+
}
|
|
232
235
|
return null;
|
|
233
236
|
}
|
|
234
237
|
return segments.join('/');
|
|
@@ -252,8 +255,35 @@ function createSubagentBroker(options = {}) {
|
|
|
252
255
|
|
|
253
256
|
function fillSlots() {
|
|
254
257
|
while (accepting && !cancelled && queued.length && running.size < limits.maxWorkers) {
|
|
255
|
-
const
|
|
256
|
-
|
|
258
|
+
const runningFiles = new Set();
|
|
259
|
+
for (const id of running.keys()) {
|
|
260
|
+
for (const file of jobs.get(id).job.files) {
|
|
261
|
+
runningFiles.add(file);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// FIFO with skip: pick the first queued job whose ownership does not
|
|
265
|
+
// intersect any running job's files — overlapping jobs wait their turn
|
|
266
|
+
// (temporal exclusivity replaces the old overlap rejection).
|
|
267
|
+
const index = queued.findIndex(id => !jobs.get(id).job.files.some(file => runningFiles.has(file)));
|
|
268
|
+
if (index === -1) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const [jobId] = queued.splice(index, 1);
|
|
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
|
+
}
|
|
257
287
|
}
|
|
258
288
|
}
|
|
259
289
|
|
|
@@ -324,6 +354,17 @@ function createSubagentBroker(options = {}) {
|
|
|
324
354
|
entry.status = resultFields.status;
|
|
325
355
|
const ownedAfter = hashPaths(job.files);
|
|
326
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
|
+
}
|
|
327
368
|
const result = {
|
|
328
369
|
id: job.id,
|
|
329
370
|
...resultFields,
|
|
@@ -408,6 +449,10 @@ function createSubagentBroker(options = {}) {
|
|
|
408
449
|
return;
|
|
409
450
|
}
|
|
410
451
|
for (const entry of entries) {
|
|
452
|
+
// The whole queue zone (incl. the work/ slice scratch) stays out of
|
|
453
|
+
// wave hashing: scratch can never reach Overleaf, same-wave slices
|
|
454
|
+
// are all in the owned union anyway, and a lead staggering slice
|
|
455
|
+
// creation mid-wave must not read as a violation (v1.6.1).
|
|
411
456
|
if (entry.name === '.DS_Store' || entry.name === SUBAGENT_QUEUE_DIR || entry.name === '.codex-overleaf-attachments') {
|
|
412
457
|
continue;
|
|
413
458
|
}
|
|
@@ -446,7 +491,7 @@ function createSubagentBroker(options = {}) {
|
|
|
446
491
|
'You are a subagent working on one slice of a larger task.',
|
|
447
492
|
'HARD CONSTRAINTS:',
|
|
448
493
|
`- You may modify ONLY these files: ${job.files.join(', ')}.`,
|
|
449
|
-
readOnly + '- Do not modify, create, or delete any other file.
|
|
494
|
+
readOnly + '- Do not modify, create, or delete any other file. Inside .codex-overleaf-subagents/ you may touch ONLY the slice files listed above (if any).',
|
|
450
495
|
'- Work fully autonomously; nobody can answer questions.',
|
|
451
496
|
'',
|
|
452
497
|
job.task
|
|
@@ -475,19 +520,39 @@ function createSubagentBroker(options = {}) {
|
|
|
475
520
|
|
|
476
521
|
async function stop({ drain = true } = {}) {
|
|
477
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
|
+
}
|
|
478
533
|
if (drain && running.size) {
|
|
534
|
+
let graceTimer = null;
|
|
479
535
|
const grace = new Promise(resolve => {
|
|
480
|
-
setTimeout(resolve, limits.drainGraceMs);
|
|
536
|
+
graceTimer = setTimeout(resolve, limits.drainGraceMs);
|
|
481
537
|
});
|
|
482
538
|
await Promise.race([
|
|
483
539
|
Promise.allSettled([...running.values()].map(worker => worker.promise)),
|
|
484
540
|
grace
|
|
485
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
|
+
}
|
|
486
548
|
}
|
|
487
549
|
for (const { controller } of running.values()) {
|
|
488
550
|
controller.abort(new Error('broker drained'));
|
|
489
551
|
}
|
|
490
|
-
|
|
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);
|
|
491
556
|
if (jobs.size) {
|
|
492
557
|
emit('codex.subagent.drained', 'subagents drained', {
|
|
493
558
|
jobs: jobs.size,
|
|
@@ -497,6 +562,23 @@ function createSubagentBroker(options = {}) {
|
|
|
497
562
|
close();
|
|
498
563
|
}
|
|
499
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
|
+
|
|
500
582
|
function close() {
|
|
501
583
|
if (closed) {
|
|
502
584
|
return;
|