File size: 836 Bytes
26a284a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python
import sys
import os
import json
import time
from hook_utils import is_sdk_child, api_call_bg

def main():
    try:
        input_data = sys.stdin.read()
        if not input_data:
            return
        data = json.loads(input_data)
    except Exception:
        return

    if is_sdk_child(data):
        return

    session_id = data.get("session_id") or data.get("sessionId") or "unknown"

    api_call_bg("session/end", {"sessionId": session_id})

    if os.environ.get("CONSOLIDATION_ENABLED") == "true":
        api_call_bg("crystals/auto", {"olderThanDays": 0})
        api_call_bg("consolidate-pipeline", {"tier": "all", "force": True})

    if os.environ.get("CLAUDE_MEMORY_BRIDGE") == "true":
        api_call_bg("claude-bridge/sync", {})

    time.sleep(1.5)

if __name__ == "__main__":
    main()