#!/usr/bin/env node /** * Passive recorder hook: POST one lifecycle event into the daemon and get out of the way. * * Wired to every observed event. This used to be a `type: "http"` hook — no process spawn at * all — until it turned out that Grok Build's http runner validates the URL against its SSRF * rules and rejects any scheme that is not https (crates/codegen/xai-grok-hooks/src/runner/ * http.rs, `validate_hook_url`). The daemon speaks plain http on loopback, so an http hook * could never reach it: those hooks were failing validation, silently, on every event. * * A command hook costs a Node start (~40ms) per event, and buys back the ability to send an * authentication header, which the http runner has no config surface for. * * Always exits 0. A dashboard must never be the reason a tool call fails. */ import { baseUrl, envEnvelope, hookHeaders, postJson, readConfig, readStdinJson, } from "./glance-lib.mjs"; try { const payload = envEnvelope(await readStdinJson()); const cfg = readConfig(); // Short: if the daemon is not listening this must fail fast, not hold up the tool call. await postJson(`${baseUrl(cfg)}/hook/record`, payload, 2000, hookHeaders()); } catch { // Daemon down, no secret yet, malformed payload — all the same answer: carry on. } process.exit(0);