fix(skills): resolve session resolution, add cancelled event status, and scope mqtt topic

This commit is contained in:
2026-08-05 09:11:35 +09:00
parent 68eff79810
commit ea36e81624
8 changed files with 71 additions and 44 deletions
+39 -11
View File
@@ -404,6 +404,7 @@ except Exception:
fi
;;
set-buffer)
buf="tmp_buffer"
text=""
while [ $# -gt 0 ]; do
case "$1" in
@@ -412,18 +413,25 @@ except Exception:
echo "Error: -b requires a value" >&2
exit 1
fi
buf="$2"
buf="$(echo "$2" | tr -cd 'A-Za-z0-9_.-')"
if [ -z "$buf" ]; then buf="tmp_buffer"; else buf="buf_$buf"; fi
shift 2
;;
*) text="$1"; shift ;;
esac
done
echo -n "$text" > "$wrapper_dir/tmp_buffer"
echo -n "$text" > "$wrapper_dir/$buf"
;;
paste-buffer)
buf="tmp_buffer"
sess=""
while [ $# -gt 0 ]; do
case "$1" in
-b)
buf="$(echo "$2" | tr -cd 'A-Za-z0-9_.-')"
if [ -z "$buf" ]; then buf="tmp_buffer"; else buf="buf_$buf"; fi
shift 2
;;
-t)
if [ $# -lt 2 ]; then
echo "Error: -t requires a value" >&2
@@ -435,12 +443,26 @@ except Exception:
*) shift ;;
esac
done
if [ -f "$wrapper_dir/tmp_buffer" ]; then
_real_herdr agent send "$sess" "$(cat "$wrapper_dir/tmp_buffer")" >/dev/null 2>&1 || true
if [ -f "$wrapper_dir/$buf" ]; then
_real_herdr agent send "$sess" "$(cat "$wrapper_dir/$buf")" >/dev/null 2>&1 || true
else
echo "Error: buffer $buf not found" >&2
exit 1
fi
;;
delete-buffer)
rm -f "$wrapper_dir/tmp_buffer"
buf="tmp_buffer"
while [ $# -gt 0 ]; do
case "$1" in
-b)
buf="$(echo "$2" | tr -cd 'A-Za-z0-9_.-')"
if [ -z "$buf" ]; then buf="tmp_buffer"; else buf="buf_$buf"; fi
shift 2
;;
*) shift ;;
esac
done
rm -f "$wrapper_dir/$buf"
;;
ls)
_real_herdr agent list 2>/dev/null | python3 -c "
@@ -451,7 +473,7 @@ try:
for a in res.get('agents', []):
try:
name = a.get('name') or a.get('agent') or 'unknown'
print(f\"{name}|0\")
print(f\"{name}|\")
except Exception:
pass
except Exception:
@@ -659,8 +681,11 @@ env_python() {
_check_is_nfs() {
local f="$1"
local mountpoint
mountpoint="$(df --output=target "$f" 2>/dev/null | tail -1)" || return 1
if mount | grep -q "$mountpoint.*nfs\|$mountpoint.*cifs\|$mountpoint.*fuse.sshfs"; then
mountpoint="$(df --output=target "$f" 2>/dev/null | tail -1)"
if [ -z "$mountpoint" ]; then
mountpoint="$(df -P "$f" 2>/dev/null | tail -1 | awk '{print $6}')"
fi
if [ -n "$mountpoint" ] && mount | grep -i -q -E "$mountpoint.*(nfs|cifs|smb|sshfs)"; then
return 0 # is NFS
fi
return 1 # not NFS
@@ -1221,7 +1246,10 @@ elif agent == 'cline':
emit(cand)
ai = {}
db_path = f"{mam_dir}/agent-sessions.db" if 'mam_dir' in locals() else os.path.join(ws, ".mam", "agent-sessions.db")
yaml_path = f"{mam_dir}/agent-sessions.yaml" if 'mam_dir' in locals() else os.path.join(ws, ".mam", "agent-sessions.yaml")
try:
import yaml
if os.path.exists(db_path):
conn = sqlite3.connect(db_path, timeout=60.0)
row = conn.execute('SELECT data FROM state WHERE id=1').fetchone()
@@ -1232,8 +1260,8 @@ try:
with open(yaml_path) as f:
d = yaml.safe_load(f) or {}
ai = d.get('agent_identities', {})
except Exception:
pass
except Exception as e:
print(f"WARN: tier-3 identity lookup failed: {e}", file=sys.stderr)
ai_agent = ai.get(agent) or {}
if ai_agent.get('project_cwd') == ws:
@@ -1242,7 +1270,7 @@ if ai_agent.get('project_cwd') == ws:
if cand and verify_session_uuid(ws, agent, cand, mode="revalidate"):
emit(cand)
elif agent == 'agy':
cand = ai.get('conversation_id')
cand = ai_agent.get('conversation_id')
if cand and verify_session_uuid(ws, agent, cand, mode="revalidate"):
emit(cand)
elif agent == 'hermes':