Spaces:
Running
Running
File size: 1,107 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 36 37 38 39 40 41 42 43 44 | #!/usr/bin/env python
import sys
import json
import time
from datetime import datetime
from hook_utils import resolve_project, 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
notification_type = data.get("notification_type") or data.get("notificationType")
if notification_type != "permission_prompt":
return
session_id = data.get("session_id") or data.get("sessionId") or "unknown"
payload = {
"hookType": "notification",
"sessionId": session_id,
"project": resolve_project(data.get("cwd")),
"cwd": data.get("cwd") or "",
"timestamp": datetime.utcnow().isoformat() + "Z",
"data": {
"notification_type": notification_type,
"title": data.get("title"),
"message": data.get("message")
}
}
api_call_bg("observe", payload)
time.sleep(0.5)
if __name__ == "__main__":
main()
|