codex-overleaf-link 2.5.1 → 2.6.5

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.
Files changed (111) hide show
  1. package/README.md +149 -398
  2. package/README.zh-CN.md +153 -404
  3. package/extension/bootstrap/manifest.template.json +1 -1
  4. package/extension/src/background.js +148 -3
  5. package/extension/src/backgroundSharedSessions.js +55 -2
  6. package/extension/src/backgroundUpdateCoordinator.js +128 -12
  7. package/extension/src/content/activeTurnControl.js +164 -7
  8. package/extension/src/content/composerAttachments.js +46 -10
  9. package/extension/src/content/composerPanel.js +92 -12
  10. package/extension/src/content/contentRuntime.js +1114 -321
  11. package/extension/src/content/contextTray.js +8 -2
  12. package/extension/src/content/contextUsageView.js +267 -0
  13. package/extension/src/content/diagnosticsController.js +77 -34
  14. package/extension/src/content/diagnosticsExport.js +1 -1
  15. package/extension/src/content/diagnosticsPanel.js +147 -42
  16. package/extension/src/content/generated/content.bundle.js +5761 -1237
  17. package/extension/src/content/generated/content.bundle.meta.json +6 -3
  18. package/extension/src/content/legacyGlobalRegistry.js +4 -0
  19. package/extension/src/content/localSkillsPanel.js +6 -4
  20. package/extension/src/content/markdownDomRenderer.js +5 -3
  21. package/extension/src/content/markdownText.js +53 -14
  22. package/extension/src/content/modelPicker.js +29 -19
  23. package/extension/src/content/nativeCompatibilityController.js +52 -19
  24. package/extension/src/content/otWarmMirror.js +1 -1
  25. package/extension/src/content/pageBridgeClient.js +7 -7
  26. package/extension/src/content/panelMaintenance.js +10 -2
  27. package/extension/src/content/panelRenderer.js +55 -28
  28. package/extension/src/content/pendingInputView.js +1 -1
  29. package/extension/src/content/projectSettingsCoordinator.js +30 -6
  30. package/extension/src/content/providerSettingsDialog.js +28 -19
  31. package/extension/src/content/recentProjects.js +30 -19
  32. package/extension/src/content/runActivitySummary.js +122 -14
  33. package/extension/src/content/runCompletionMeta.js +194 -6
  34. package/extension/src/content/runController.js +2 -1
  35. package/extension/src/content/runFailureNotice.js +8 -1
  36. package/extension/src/content/runPresence.js +18 -8
  37. package/extension/src/content/runQueueScheduler.js +27 -13
  38. package/extension/src/content/runRecoveryActions.js +2 -1
  39. package/extension/src/content/runResultActions.js +73 -24
  40. package/extension/src/content/runReviewController.js +102 -37
  41. package/extension/src/content/runTimelineView.js +224 -25
  42. package/extension/src/content/scopedPersistencePanelState.js +124 -46
  43. package/extension/src/content/selectionContextView.js +30 -3
  44. package/extension/src/content/sensitivePreflight.js +14 -1
  45. package/extension/src/content/sessionManager.js +49 -3
  46. package/extension/src/content/sessionMenuView.js +54 -18
  47. package/extension/src/content/sessionPersistence.js +25 -5
  48. package/extension/src/content/settingsPanel.js +15 -2
  49. package/extension/src/content/settingsWorkbench.js +127 -89
  50. package/extension/src/content/sharedSessionViewSync.js +13 -4
  51. package/extension/src/content/subagentActivityView.js +23 -7
  52. package/extension/src/content/updateNotice.js +60 -6
  53. package/extension/src/content/writebackOrchestrator.js +301 -72
  54. package/extension/src/content/writingStyleSettings.js +70 -17
  55. package/extension/src/page/compileBridge.js +193 -180
  56. package/extension/src/page/overleafCapabilities.js +4 -1
  57. package/extension/src/page/overleafEditor.js +12 -3
  58. package/extension/src/page/overleafProjectSnapshot.js +56 -3
  59. package/extension/src/page/snapshotRouter.js +75 -66
  60. package/extension/src/page/textCoordinates.js +17 -1
  61. package/extension/src/page/textFileCreator.js +9 -1
  62. package/extension/src/page/treeOperations.js +200 -19
  63. package/extension/src/page/writebackRouter.js +172 -113
  64. package/extension/src/pageBridge.js +124 -73
  65. package/extension/src/popup.js +1 -1
  66. package/extension/src/shared/agentTranscript.js +372 -18
  67. package/extension/src/shared/auditRecords.js +3 -0
  68. package/extension/src/shared/compatibility.js +1 -1
  69. package/extension/src/shared/compileAdapter.js +58 -17
  70. package/extension/src/shared/composerAttachmentDraft.js +27 -7
  71. package/extension/src/shared/contextUsage.js +125 -0
  72. package/extension/src/shared/failureReasons.js +57 -3
  73. package/extension/src/shared/i18n.js +315 -29
  74. package/extension/src/shared/lineReferences.js +38 -31
  75. package/extension/src/shared/pageRpcContract.js +1 -1
  76. package/extension/src/shared/panelIcons.js +39 -0
  77. package/extension/src/shared/projectFiles.js +2 -1
  78. package/extension/src/shared/reviewing.js +130 -1
  79. package/extension/src/shared/runActivityModel.js +70 -4
  80. package/extension/src/shared/runExecutionSnapshot.js +13 -0
  81. package/extension/src/shared/scopedPersistenceBrowserAdapter.js +34 -0
  82. package/extension/src/shared/sessionState.js +63 -4
  83. package/extension/src/shared/sessionTitle.js +14 -1
  84. package/extension/src/shared/sharedSessionBridge.js +81 -13
  85. package/extension/src/shared/staleGuard.js +130 -63
  86. package/extension/src/shared/storageDb.js +35 -3
  87. package/extension/src/shared/storageMigration.js +111 -2
  88. package/extension/src/shared/storageRunActions.js +62 -8
  89. package/extension/src/shared/undoOperations.js +126 -28
  90. package/extension/src/shared/updateRuntimeIdentity.js +16 -2
  91. package/extension/src/shared/writebackSettlement.js +21 -3
  92. package/extension/styles/panel.css +1293 -549
  93. package/native-host/src/bootstrapUpdate.js +52 -16
  94. package/native-host/src/chatBridgeRequest.js +60 -6
  95. package/native-host/src/chatBridgeResponse.js +10 -1
  96. package/native-host/src/chatCompletionsBridge.js +29 -2
  97. package/native-host/src/codexPromptAssembly.js +86 -118
  98. package/native-host/src/codexSessionRunner.js +127 -17
  99. package/native-host/src/debugLog.js +27 -3
  100. package/native-host/src/index.js +42 -11
  101. package/native-host/src/localSkills.js +1 -1
  102. package/native-host/src/mirrorWorkspace.js +47 -3
  103. package/native-host/src/nativeEnvironment.js +27 -5
  104. package/native-host/src/providerContextError.js +20 -0
  105. package/native-host/src/providerRuntime.js +1 -0
  106. package/native-host/src/skills/reviewer-response/SKILL.md +65 -0
  107. package/native-host/src/taskRunnerRuntime.js +28 -8
  108. package/native-host/src/textPatch.js +473 -377
  109. package/native-host/src/updateManager.js +144 -21
  110. package/native-host/src/writingStyleRuntime.js +1 -1
  111. package/package.json +5 -8
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: reviewer-response
3
+ description: >
4
+ Use only when the user asks to respond to peer-review or reviewer comments,
5
+ write a rebuttal or response letter, or plan a revision from reviews.
6
+ ---
7
+
8
+ # Reviewer Response
9
+
10
+ Map reviewer comments to evidence in the paper, proposed edits, and reply
11
+ drafts. Keep missing evidence visible instead of filling it with assumptions.
12
+
13
+ ## Workflow
14
+
15
+ 1. Split the reviews into atomic comments with stable IDs R<reviewer>.<n>,
16
+ such as R1.2. Keep the reviewer's own numbering when present; retain the
17
+ original label when splitting a numbered comment into smaller items.
18
+ 2. For each comment, look for evidence in the project files. Cite actual
19
+ source lines as plain-text path:line or path:start-end, for example
20
+ main.tex:212-230. Do not wrap references in backticks: the panel turns
21
+ plain-text references into clickable links. If evidence is absent, write
22
+ "Not found"; distinguish files not read from files searched without a match.
23
+ 3. Output a compact ledger table with these columns:
24
+
25
+ ID | Comment | Evidence in the paper | Proposed change | Status
26
+
27
+ Keep cells short for the narrow panel, with each Comment at most about
28
+ 12 words. Put necessary explanations below the table. Use only these
29
+ statuses, adding a short reason:
30
+ - Ready to edit: the evidence supports a specific local edit.
31
+ - Needs an experiment: new experimental evidence is required.
32
+ - Needs author input: facts or a decision must come from the author.
33
+ - Unresolved: the comment remains open for another stated reason.
34
+ - No change: explain why the current paper already addresses the comment
35
+ or why a change is unwarranted.
36
+
37
+ Write the table and explanations in the user's language, translating
38
+ headings, statuses, and "Not found" accordingly. Keep the IDs unchanged.
39
+ 4. After the ledger, draft replies only for the comments the user asked
40
+ about, or for every comment when they requested a full response letter.
41
+ Write reply drafts in English unless the user asks otherwise. Label each
42
+ draft with its comment ID and distinguish proposed work from completed work.
43
+ 5. Finish with one "Next:" line, localized to the user's language, explaining
44
+ how to apply approved items. For example: Next: after approving R1.2,
45
+ switch to Auto and send "Apply R1.2".
46
+
47
+ ## Integrity rules
48
+
49
+ - Never invent results, numbers, experiments, citations, or completed changes.
50
+ - Anything needed for a response that is not present in the paper or provided
51
+ by the user must be marked Needs an experiment or Needs author input.
52
+ - Reply drafts must not promise results. State missing evidence or pending
53
+ author input explicitly; do not describe planned edits as already made.
54
+ - Cite only files and lines actually inspected. User-provided facts are not
55
+ evidence already in the paper; identify their source separately.
56
+
57
+ ## Editing rules
58
+
59
+ - In Ask mode, never edit files.
60
+ - In Auto mode, edit only the comment IDs the user explicitly approves.
61
+ Keep edits minimal and local, leaving unrelated text untouched. An approved
62
+ ID does not authorize inventing missing evidence or results.
63
+ - After editing, report which IDs changed with plain-text path:line or
64
+ path:start-end references. Keep pending items separate and do not claim
65
+ an edit, save, or experiment completed without evidence.
@@ -50,7 +50,7 @@ const activeRunEntries = new Map();
50
50
  // Overleaf tab was reloaded — the requestId lived in content-side JS state
51
51
  // and is gone, but the native-host-side controller is still running).
52
52
  const activeRunByProject = new Map();
53
- const CODEX_RUN_PASSTHROUGH_ERROR_CODES = new Set(['thread_resume_failed', 'codex_no_usable_result', 'codex_process_stop_unconfirmed', 'selected_context_unresolved', 'codex_local_skill_unavailable']);
53
+ const CODEX_RUN_PASSTHROUGH_ERROR_CODES = new Set(['thread_resume_failed', 'codex_no_usable_result', 'codex_context_limit', 'codex_process_stop_unconfirmed', 'selected_context_unresolved', 'codex_local_skill_unavailable', 'document_identity_mismatch']);
54
54
 
55
55
  async function handleRequest(request, env = process.env, emit = () => {}) {
56
56
  if (!request || typeof request !== 'object') {
@@ -72,7 +72,7 @@ async function handleRequest(request, env = process.env, emit = () => {}) {
72
72
  platform: getNativeRuntimePlatform({ env }),
73
73
  protocolVersion: 2,
74
74
  supportedProtocol: { ...SUPPORTED_NATIVE_PROTOCOL },
75
- capabilities: { ...Object.fromEntries(REQUIRED_CAPABILITIES.map(capability => [capability, true])), literalProjectPaths: true },
75
+ capabilities: { ...Object.fromEntries(REQUIRED_CAPABILITIES.map(capability => [capability, true])), literalProjectPaths: true, threadCompact: true },
76
76
  minExtensionVersion: MIN_COMPATIBLE_EXTENSION_VERSION,
77
77
  version: PACKAGE_VERSION,
78
78
  environment: summarizeNativeEnvironment(env)
@@ -213,6 +213,13 @@ async function handleCodexRun(request, env, emit) {
213
213
  const identity = NativeRequestIdentity.validate(request.id);
214
214
  if (!identity.ok) return errorResponse(request.id, identity.error.code, identity.error.message, identity.error.details);
215
215
  let params = request.params || {};
216
+ if (params.operation === 'compact') {
217
+ if (typeof params.threadId !== 'string' || !params.threadId.trim() || params.threadId.length > 160
218
+ || typeof params.projectId !== 'string' || !params.projectId.trim()) {
219
+ return errorResponse(request.id, 'codex_compact_thread_required', 'Compaction requires an existing project conversation.');
220
+ }
221
+ params = { ...params, threadId: params.threadId.trim(), mode: 'ask', writingStyleBuild: undefined };
222
+ }
216
223
  if (params.writingStyleBuild != null) {
217
224
  if (typeof params.writingStyleBuild !== 'object' || Array.isArray(params.writingStyleBuild)) {
218
225
  return errorResponse(request.id, 'writing_style_invalid_build', 'Writing style build settings must be an object.');
@@ -272,7 +279,9 @@ async function handleCodexRun(request, env, emit) {
272
279
  }
273
280
 
274
281
  abortController.signal.throwIfAborted();
275
- if (params.useExistingMirror) {
282
+ // Compaction only updates the captured thread; it neither refreshes the
283
+ // project mirror nor accepts document overlays as part of this request.
284
+ if (params.operation !== 'compact' && params.useExistingMirror) {
276
285
  const { getMirrorStatus, applyFileOverlays } = require('./mirrorWorkspace');
277
286
  const rootDir = env.CODEX_OVERLEAF_MIRROR_ROOT;
278
287
  const status = getMirrorStatus(projectKey, { rootDir });
@@ -299,9 +308,9 @@ async function handleCodexRun(request, env, emit) {
299
308
  // OT overlays prove that the current page agrees with the trusted OT
300
309
  // baseline; they must not rewrite it or supply a replacement hash.
301
310
  if (!isOtWarmMirrorReuseRequest(params) && Array.isArray(params.fileOverlays) && params.fileOverlays.length) {
302
- await applyFileOverlays({ projectId: projectKey, overlays: params.fileOverlays, rootDir });
311
+ await applyFileOverlays({ projectId: projectKey, evidenceProjectId: params.projectId, overlays: params.fileOverlays, rootDir });
303
312
  }
304
- } else if (!params.writingStyleBuild && !isSnapshotlessSkillInstallerRun(params) && !hasRunnableProjectSnapshotEvidence(params)) {
313
+ } else if (params.operation !== 'compact' && !params.writingStyleBuild && !isSnapshotlessSkillInstallerRun(params) && !hasRunnableProjectSnapshotEvidence(params)) {
305
314
  return errorResponse(
306
315
  request.id,
307
316
  'codex_run_requires_snapshot_evidence',
@@ -377,6 +386,9 @@ async function handleCodexSteer(request) {
377
386
  if (!entry?.control) {
378
387
  return errorResponse(request.id, 'codex_turn_not_ready', 'The active Codex turn is not ready for guidance.');
379
388
  }
389
+ if (entry.control.operation === 'compact') {
390
+ return errorResponse(request.id, 'codex_compact_not_steerable', 'Wait for context compaction to finish before sending a message.');
391
+ }
380
392
  const expectedThreadId = String(params.threadId || '');
381
393
  const expectedTurnId = String(params.expectedTurnId || params.turnId || '');
382
394
  if ((expectedThreadId && expectedThreadId !== entry.control.threadId)
@@ -444,6 +456,13 @@ function handleCodexCancel(request, env = process.env) {
444
456
  });
445
457
  }
446
458
 
459
+ if (targetId != null && !force) {
460
+ return okResponse(request.id, {
461
+ cancelled: false,
462
+ reason: 'request_not_active'
463
+ });
464
+ }
465
+
447
466
  if (projectKey) {
448
467
  const entry = activeRunByProject.get(projectKey);
449
468
  if (entry?.controller) {
@@ -681,14 +700,14 @@ function createCancellationError() {
681
700
  }
682
701
 
683
702
  function isCancellationError(error = {}) {
684
- if (['codex_turn_failed', 'codex_turn_status_invalid'].includes(error.code)) return false;
703
+ if (['codex_turn_failed', 'codex_turn_status_invalid', 'codex_context_limit'].includes(error.code)) return false;
685
704
  return error.code === 'codex_cancelled'
686
705
  || error.name === 'AbortError'
687
706
  || /cancelled by the user|was cancelled/i.test(error.message || '');
688
707
  }
689
708
 
690
709
  function shouldPassthroughCodexRunError(error = {}) {
691
- return CODEX_RUN_PASSTHROUGH_ERROR_CODES.has(error.code);
710
+ return CODEX_RUN_PASSTHROUGH_ERROR_CODES.has(error.code) || String(error.code || '').startsWith('codex_compact_');
692
711
  }
693
712
 
694
713
  function isCodexMissing(env = process.env) {
@@ -721,6 +740,7 @@ async function handleMirrorSync(request, env) {
721
740
  try {
722
741
  const result = await syncOverleafToMirror({
723
742
  projectId,
743
+ evidenceProjectId: params.projectId,
724
744
  project: params.project || { files: [] },
725
745
  rootDir
726
746
  });
@@ -757,7 +777,7 @@ async function handleMirrorPatchFiles(request, env) {
757
777
  });
758
778
  return okResponse(request.id, result);
759
779
  } catch (error) {
760
- return errorResponse(request.id, 'mirror_patch_files_failed', error.message);
780
+ return errorResponse(request.id, error.code === 'document_identity_mismatch' ? error.code : 'mirror_patch_files_failed', error.message);
761
781
  } finally {
762
782
  releaseProjectLock(projectKey, lockToken);
763
783
  }