@codemoot/cli 0.2.12 → 0.2.13

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/dist/index.js CHANGED
@@ -447,11 +447,23 @@ Review for:
447
447
  constraints: run.reviewCycles > 0 ? [`This is review cycle ${run.reviewCycles + 1}. Focus on whether prior issues were addressed.`] : void 0
448
448
  });
449
449
  const progress = createProgressCallbacks("build-review");
450
- const result = await adapter.callWithResume(prompt, {
451
- sessionId: existingSession,
452
- timeout: 6e5,
453
- ...progress
454
- });
450
+ let result;
451
+ try {
452
+ result = await adapter.callWithResume(prompt, {
453
+ sessionId: existingSession,
454
+ timeout: 6e5,
455
+ ...progress
456
+ });
457
+ } catch (err) {
458
+ if (existingSession) {
459
+ console.error(chalk3.yellow(" Clearing stale codex thread ID after failure."));
460
+ sessionMgr.updateThreadId(session2.id, null);
461
+ }
462
+ throw err;
463
+ }
464
+ if (existingSession && result.sessionId !== existingSession) {
465
+ sessionMgr.updateThreadId(session2.id, null);
466
+ }
455
467
  if (result.sessionId) {
456
468
  sessionMgr.updateThreadId(session2.id, result.sessionId);
457
469
  }
@@ -1310,7 +1322,18 @@ IMPORTANT KEY FORMAT: The key will be built as scope:file:symbol \u2014 use the
1310
1322
  });
1311
1323
  try {
1312
1324
  const progress = createProgressCallbacks("cleanup-scan");
1313
- const result = await adapter.callWithResume(prompt, { sessionId: sessionThreadId, timeout: timeoutSec * 1e3, ...progress });
1325
+ let result;
1326
+ try {
1327
+ result = await adapter.callWithResume(prompt, { sessionId: sessionThreadId, timeout: timeoutSec * 1e3, ...progress });
1328
+ } catch (err) {
1329
+ if (sessionThreadId && sessionMgr && sessionId) {
1330
+ sessionMgr.updateThreadId(sessionId, null);
1331
+ }
1332
+ throw err;
1333
+ }
1334
+ if (sessionThreadId && result.sessionId !== sessionThreadId && sessionMgr && sessionId) {
1335
+ sessionMgr.updateThreadId(sessionId, null);
1336
+ }
1314
1337
  if (sessionMgr && sessionId) {
1315
1338
  if (result.sessionId) {
1316
1339
  sessionMgr.updateThreadId(sessionId, result.sessionId);
@@ -3076,11 +3099,23 @@ Output format:
3076
3099
  const timeoutMs = (options.timeout ?? 300) * 1e3;
3077
3100
  const progress = createProgressCallbacks("plan-review");
3078
3101
  console.error(chalk15.cyan("Sending plan to codex for review..."));
3079
- const result = await adapter.callWithResume(prompt, {
3080
- sessionId: threadId,
3081
- timeout: timeoutMs,
3082
- ...progress
3083
- });
3102
+ let result;
3103
+ try {
3104
+ result = await adapter.callWithResume(prompt, {
3105
+ sessionId: threadId,
3106
+ timeout: timeoutMs,
3107
+ ...progress
3108
+ });
3109
+ } catch (err) {
3110
+ if (threadId) {
3111
+ console.error(chalk15.yellow(" Clearing stale codex thread ID after failure."));
3112
+ sessionMgr.updateThreadId(session2.id, null);
3113
+ }
3114
+ throw err;
3115
+ }
3116
+ if (threadId && result.sessionId !== threadId) {
3117
+ sessionMgr.updateThreadId(session2.id, null);
3118
+ }
3084
3119
  if (result.sessionId) {
3085
3120
  sessionMgr.updateThreadId(session2.id, result.sessionId);
3086
3121
  }