fix(agents): open agy, codex and hermes databases read-only (Issue #64)

This commit is contained in:
Godopu committed 2026-10-19 23:12:55 +09:00
1 parent 3ce5d5fdc1
commit b0eccc5301
8 files changed
+461 -56

No files matched your search

@@ -87,8 +87,8 @@ def resume_on_disk(s):
if not os.path.exists(hdb):
return 'MISSING'
try:
import sqlite3
conn = sqlite3.connect(hdb)
from lib_py.agents.base import _ro_connect
conn = _ro_connect(hdb)
r = conn.execute("SELECT 1 FROM sessions WHERE id=?", (u,)).fetchone()
conn.close()
return 'yes' if r else 'MISSING'
@@ -107,13 +107,12 @@ def resume_on_disk(s):
if u:
# the adapter's db: `opencode debug paths`, which follows XDG_DATA_HOME (Issue #60)
from lib_py.agents.registry import get_adapter
from lib_py.agents.base import DiscoveryContext
from lib_py.agents.base import DiscoveryContext, _ro_connect
odb = get_adapter('opencode')._resolve_db(DiscoveryContext(workspace=cwd, agent_name='opencode', home_dir=home))
if not odb or not os.path.exists(odb):
return 'MISSING'
try:
# read-only: nothing is created or removed beside the agent's db (Issue #60)
from lib_py.agents.adapters.opencode import _ro_connect
conn = _ro_connect(odb)
r = conn.execute("SELECT 1 FROM session_v2 WHERE id=?", (u,)).fetchone() # opencode 2.x
conn.close()
@@ -129,8 +128,8 @@ def resume_on_disk(s):
if db_matches:
db = max(db_matches, key=os.path.getmtime)
try:
import sqlite3
conn = sqlite3.connect(db)
from lib_py.agents.base import _ro_connect
conn = _ro_connect(db)
r = conn.execute("SELECT rollout_path FROM threads WHERE id=?", (u,)).fetchone()
conn.close()
if r and r[0] and os.path.exists(r[0]):
@@ -288,8 +287,8 @@ def resume_on_disk(s):
if not os.path.exists(hdb):
return 'MISSING'
try:
import sqlite3
conn = sqlite3.connect(hdb)
from lib_py.agents.base import _ro_connect
conn = _ro_connect(hdb)
r = conn.execute("SELECT 1 FROM sessions WHERE id=?", (u,)).fetchone()
conn.close()
return 'yes' if r else 'MISSING'
@@ -308,13 +307,12 @@ def resume_on_disk(s):
if u:
# the adapter's db: `opencode debug paths`, which follows XDG_DATA_HOME (Issue #60)
from lib_py.agents.registry import get_adapter
from lib_py.agents.base import DiscoveryContext
from lib_py.agents.base import DiscoveryContext, _ro_connect
odb = get_adapter('opencode')._resolve_db(DiscoveryContext(workspace=cwd, agent_name='opencode', home_dir=home))
if not odb or not os.path.exists(odb):
return 'MISSING'
try:
# read-only: nothing is created or removed beside the agent's db (Issue #60)
from lib_py.agents.adapters.opencode import _ro_connect
conn = _ro_connect(odb)
r = conn.execute("SELECT 1 FROM session_v2 WHERE id=?", (u,)).fetchone() # opencode 2.x
conn.close()
@@ -330,8 +328,8 @@ def resume_on_disk(s):
if db_matches:
db = max(db_matches, key=os.path.getmtime)
try:
import sqlite3
conn = sqlite3.connect(db)
from lib_py.agents.base import _ro_connect
conn = _ro_connect(db)
r = conn.execute("SELECT rollout_path FROM threads WHERE id=?", (u,)).fetchone()
conn.close()
if r and r[0] and os.path.exists(r[0]):