fix(codex): purge removes tui-thread-reference-capabilities/<uuid> (#78)
This commit is contained in:
1 parent
c6eb4564d2
commit
51dfd38f0b
2 files changed
+98
-4
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import os, json, glob, sqlite3, subprocess
|
||||
import os, json, glob, shutil, sqlite3, subprocess
|
||||
from typing import Optional, Any, List
|
||||
from lib_py.agents.base import BaseAgentAdapter, DiscoveryContext, _ro_connect, scan_names, db_rows_naming
|
||||
from lib_py.agents.base import BaseAgentAdapter, DiscoveryContext, _plausible_id, _ro_connect, scan_names, db_rows_naming
|
||||
from lib_py.verify_session import workspace_key
|
||||
|
||||
class CodexAgentAdapter(BaseAgentAdapter):
|
||||
@@ -131,6 +131,22 @@ class CodexAgentAdapter(BaseAgentAdapter):
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def _purge_tui_thread_capability(self, uuid: str, ctx: DiscoveryContext, purged: List[str]) -> None:
|
||||
if not _plausible_id(uuid):
|
||||
return
|
||||
cap = os.path.join(self._codex_home(ctx), "tui-thread-reference-capabilities", uuid)
|
||||
if not os.path.lexists(cap):
|
||||
return
|
||||
try:
|
||||
if os.path.isdir(cap) and not os.path.islink(cap):
|
||||
shutil.rmtree(cap)
|
||||
else:
|
||||
os.unlink(cap)
|
||||
if not os.path.lexists(cap):
|
||||
purged.append(cap)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def purge_artifacts(self, uuid: str, ctx: DiscoveryContext) -> List[str]:
|
||||
purged = []
|
||||
path = self._find_rollout(uuid, ctx)
|
||||
@@ -140,12 +156,16 @@ class CodexAgentAdapter(BaseAgentAdapter):
|
||||
if res.returncode == 0:
|
||||
if path:
|
||||
purged.append(path)
|
||||
self._purge_tui_thread_capability(uuid, ctx, purged)
|
||||
return purged
|
||||
except Exception:
|
||||
pass
|
||||
if path and os.path.exists(path):
|
||||
os.remove(path)
|
||||
purged.append(path)
|
||||
try:
|
||||
os.remove(path)
|
||||
purged.append(path)
|
||||
except Exception:
|
||||
pass
|
||||
db = self._state_db(ctx)
|
||||
if db and os.path.exists(db):
|
||||
try:
|
||||
@@ -156,6 +176,7 @@ class CodexAgentAdapter(BaseAgentAdapter):
|
||||
purged.append(f"state db row for thread: {uuid}")
|
||||
except Exception:
|
||||
pass
|
||||
self._purge_tui_thread_capability(uuid, ctx, purged)
|
||||
return purged
|
||||
|
||||
def residual_artifacts(self, uuid: str, ctx: DiscoveryContext) -> List[str]:
|
||||
|
||||
Reference in new issue
Block a user