refactor(isolation): simplify agent session isolation and remove legacy home-isolation helpers
This commit is contained in:
@@ -319,6 +319,7 @@ exec(os.environ['MAM_VERIFY_PY'])
|
||||
|
||||
yaml_path = os.environ['YAML_PATH']
|
||||
home = os.environ['HOME_DIR']
|
||||
skills_dir = os.environ.get('SKILLS_DIR', '')
|
||||
claude_project_dir = os.environ.get('CLAUDE_PROJECT_DIR', f"{home}/.claude/projects")
|
||||
|
||||
now_iso = datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
@@ -529,8 +530,7 @@ for s in d.get('herdr_sessions', []):
|
||||
if not cwd:
|
||||
continue
|
||||
key = workspace_key(cwd)
|
||||
iso = s.get('isolation', {}).get('root') if isinstance(s.get('isolation'), dict) else None
|
||||
proj_dir = f"{iso}/projects/{key}" if iso else f"{claude_project_dir}/{key}"
|
||||
proj_dir = f"{claude_project_dir}/{key}"
|
||||
if not os.path.isdir(proj_dir):
|
||||
continue
|
||||
jsonls = sorted(glob.glob(f"{proj_dir}/*.jsonl"), key=os.path.getmtime, reverse=True)
|
||||
@@ -563,16 +563,26 @@ for s in d.get('herdr_sessions', []):
|
||||
cwd = (s.get('pane') or {}).get('cwd', '')
|
||||
if not cwd:
|
||||
continue
|
||||
iso = s.get('isolation', {}).get('root') if isinstance(s.get('isolation'), dict) else None
|
||||
conv_dir = f"{iso}/.gemini/antigravity-cli/conversations" if iso else f"{home}/.gemini/antigravity-cli/conversations"
|
||||
conv_dir = f"{home}/.gemini/antigravity-cli/conversations"
|
||||
if not os.path.isdir(conv_dir):
|
||||
continue
|
||||
dbs = sorted(glob.glob(f"{conv_dir}/*.db"), key=os.path.getmtime, reverse=True)
|
||||
|
||||
sibling_claimed = [
|
||||
other.get('agy_conversation_id_own')
|
||||
for other in d.get('herdr_sessions', [])
|
||||
if other is not s
|
||||
and (other.get('pane') or {}).get('cwd') == cwd
|
||||
and other.get('status') not in ('stopped', 'terminated')
|
||||
and other.get('agy_conversation_id_own')
|
||||
]
|
||||
s_eval = dict(s)
|
||||
s_eval['_sibling_claimed_uuids'] = sibling_claimed
|
||||
|
||||
valid_candidates = []
|
||||
for db in dbs:
|
||||
uuid = os.path.basename(db)[:-3]
|
||||
if verify_session_uuid(cwd, 'agy', uuid, s, mode="discover"):
|
||||
if verify_session_uuid(cwd, 'agy', uuid, s_eval, mode="discover"):
|
||||
valid_candidates.append(uuid)
|
||||
|
||||
if len(valid_candidates) == 1:
|
||||
@@ -597,8 +607,7 @@ for s in d.get('herdr_sessions', []):
|
||||
cwd = (s.get('pane') or {}).get('cwd', '')
|
||||
if not cwd:
|
||||
continue
|
||||
iso = s.get('isolation', {}).get('root') if isinstance(s.get('isolation'), dict) else None
|
||||
hdb = f"{iso}/.hermes/state.db" if iso else f"{home}/.hermes/state.db"
|
||||
hdb = f"{home}/.hermes/state.db"
|
||||
if not os.path.exists(hdb):
|
||||
continue
|
||||
|
||||
@@ -636,8 +645,7 @@ for s in d.get('herdr_sessions', []):
|
||||
cwd = (s.get('pane') or {}).get('cwd', '')
|
||||
if not cwd:
|
||||
continue
|
||||
iso = s.get('isolation', {}).get('root') if isinstance(s.get('isolation'), dict) else None
|
||||
sessions_dir = f"{iso}/sessions" if iso else f"{home}/.cline/data/sessions"
|
||||
sessions_dir = f"{home}/.cline/data/sessions"
|
||||
if not os.path.isdir(sessions_dir):
|
||||
continue
|
||||
candidates = []
|
||||
|
||||
Reference in New Issue
Block a user