1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!/bin/sh
# managed by herdr; reinstalling the integration replaces this file.
# HERDR_INTEGRATION_ID=letta
# HERDR_INTEGRATION_VERSION=1
[ "${1:-}" = "session" ] || exit 0
[ "${HERDR_ENV:-}" = "1" ] || exit 0
[ -n "${HERDR_PANE_ID:-}" ] || exit 0
[ -n "${HERDR_SOCKET_PATH:-}" ] || exit 0
if [ -n "${HERDR_BIN_PATH:-}" ]; then
[ -x "$HERDR_BIN_PATH" ] || exit 0
else
command -v herdr >/dev/null 2>&1 || exit 0
fi
command -v python3 >/dev/null 2>&1 || exit 0
# SessionStart stdout is injected into Letta's next user message. Keep every
# path silent, including successful reports and malformed hook input.
python3 -c '
import json
import os
import subprocess
import sys
import time
try:
payload = json.load(sys.stdin)
conversation_id = payload.get("conversation_id")
agent_id = payload.get("agent_id")
if not isinstance(conversation_id, str) or not conversation_id:
raise ValueError
if conversation_id == "default":
if not isinstance(agent_id, str) or not agent_id:
raise ValueError
session_id = "default:" + agent_id
else:
session_id = conversation_id
command = os.environ.get("HERDR_BIN_PATH") or "herdr"
args = [
command, "pane", "report-agent-session", os.environ["HERDR_PANE_ID"],
"--source", "herdr:letta", "--agent", "letta",
"--agent-session-id", session_id, "--seq", str(time.time_ns()),
"--session-start-source", "new" if payload.get("is_new_session") else "resume",
]
subprocess.run(
args,
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=1,
check=False,
)
except Exception:
pass
' 2>/dev/null || true
|