This commit is contained in:
2026-07-29 14:37:20 +00:00
parent 9c0973ead4
commit 4426ede979
33 changed files with 5128 additions and 216 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""SubagentStopguest sub agent 結束時解除它的 pin(下次啟動要重新 first-touch)。"""
from __future__ import annotations
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
import persona_lib as pl # noqa: E402
def main() -> int:
try:
event = json.load(sys.stdin)
except json.JSONDecodeError:
return 0
session_id = event.get("session_id") or "unknown"
agent_id = event.get("agent_id")
agent_type = str(event.get("agent_type") or "")
if not agent_id or "persona-guest" not in agent_type:
return 0
data = pl.load_session(session_id)
pins = data.get("pins") or {}
slug = pins.pop(agent_id, None)
if slug is not None:
pl.save_session(session_id, data)
info = (data.get("guests") or {}).get(slug) or {}
if info.get("room"):
pl.add_guest_lease(slug, session_id, info["room"], data.get("host") or "")
print(json.dumps({"suppressOutput": True}, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())