Protokoll #33930

ID33930
Zeitstempel2026-04-21 04:07:31.749095
Clientroot
IP62.246.34.195
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens978 (Input: 484, Output: 494)
Dauer58 ms
Request-Zeit2026-04-21 04:07:31.749095
Response-Zeit2026-04-21 04:07:31.807060

Request

{
    "event": "PreToolUse",
    "tool_name": "Write",
    "tool_input": {
        "file_path": "\/var\/www\/dev.campus.systemische-tools.de\/crawler\/src\/infrastructure\/fetchers\/web_vitals_collector.py",
        "content": "\"\"\"Collects Core Web Vitals via PerformanceObserver injected into the page.\"\"\"\n\nfrom __future__ import annotations\n\nfrom typing import Any\n\nINIT_SCRIPT = \"\"\"\nwindow.__webVitals = { lcp: null, cls: 0, tbt: 0 };\ntry {\n  new PerformanceObserver((list) => {\n    const last = list.getEntries().at(-1);\n    if (last) window.__webVitals.lcp = Math.round(last.startTime);\n  }).observe({ type: 'largest-contentful-paint', buffered: true });\n} catch (_) {}\ntry {\n  new PerformanceObserver((list) => {\n    for (const e of list.getEntries()) {\n      if (!e.hadRecentInput) window.__webVitals.cls += e.value;\n    }\n  }).observe({ type: 'layout-shift', buffered: true });\n} catch (_) {}\ntry {\n  new PerformanceObserver((list) => {\n    for (const e of list.getEntries()) {\n      window.__webVitals.tbt += Math.max(0, e.duration - 50);\n    }\n  }).observe({ type: 'longtask', buffered: true });\n} catch (_) {}\n\"\"\"\n\nREAD_SCRIPT = \"window.__webVitals || { lcp: null, cls: null, tbt: null }\"\n\n\ndef parse_vitals(raw: Any) -> dict[str, float | int | None]:\n    if not isinstance(raw, dict):\n        return {\"lcp_ms\": None, \"cls\": None, \"tbt_ms\": None}\n    return {\n        \"lcp_ms\": _opt_int(raw.get(\"lcp\")),\n        \"cls\": _opt_float(raw.get(\"cls\")),\n        \"tbt_ms\": _opt_int(raw.get(\"tbt\")),\n    }\n\n\ndef _opt_int(value: object) -> int | None:\n    if value is None:\n        return None\n    try:\n        return int(value)\n    except (TypeError, ValueError):\n        return None\n\n\ndef _opt_float(value: object) -> float | None:\n    if value is None:\n        return None\n    try:\n        return round(float(value), 4)\n    except (TypeError, ValueError):\n        return None\n"
    }
}

Response

{
    "tool_response": {
        "type": "create",
        "filePath": "\/var\/www\/dev.campus.systemische-tools.de\/crawler\/src\/infrastructure\/fetchers\/web_vitals_collector.py",
        "content": "\"\"\"Collects Core Web Vitals via PerformanceObserver injected into the page.\"\"\"\n\nfrom __future__ import annotations\n\nfrom typing import Any\n\nINIT_SCRIPT = \"\"\"\nwindow.__webVitals = { lcp: null, cls: 0, tbt: 0 };\ntry {\n  new PerformanceObserver((list) => {\n    const last = list.getEntries().at(-1);\n    if (last) window.__webVitals.lcp = Math.round(last.startTime);\n  }).observe({ type: 'largest-contentful-paint', buffered: true });\n} catch (_) {}\ntry {\n  new PerformanceObserver((list) => {\n    for (const e of list.getEntries()) {\n      if (!e.hadRecentInput) window.__webVitals.cls += e.value;\n    }\n  }).observe({ type: 'layout-shift', buffered: true });\n} catch (_) {}\ntry {\n  new PerformanceObserver((list) => {\n    for (const e of list.getEntries()) {\n      window.__webVitals.tbt += Math.max(0, e.duration - 50);\n    }\n  }).observe({ type: 'longtask', buffered: true });\n} catch (_) {}\n\"\"\"\n\nREAD_SCRIPT = \"window.__webVitals || { lcp: null, cls: null, tbt: null }\"\n\n\ndef parse_vitals(raw: Any) -> dict[str, float | int | None]:\n    if not isinstance(raw, dict):\n        return {\"lcp_ms\": None, \"cls\": None, \"tbt_ms\": None}\n    return {\n        \"lcp_ms\": _opt_int(raw.get(\"lcp\")),\n        \"cls\": _opt_float(raw.get(\"cls\")),\n        \"tbt_ms\": _opt_int(raw.get(\"tbt\")),\n    }\n\n\ndef _opt_int(value: object) -> int | None:\n    if value is None:\n        return None\n    try:\n        return int(value)\n    except (TypeError, ValueError):\n        return None\n\n\ndef _opt_float(value: object) -> float | None:\n    if value is None:\n        return None\n    try:\n        return round(float(value), 4)\n    except (TypeError, ValueError):\n        return None\n",
        "structuredPatch": [],
        "originalFile": null,
        "userModified": false
    }
}
← Vorheriger Zur Liste Nächster →