diff --git a/app/[locale]/continent/[slug]/page.tsx b/app/[locale]/continent/[slug]/page.tsx deleted file mode 100644 index 0ccefd8..0000000 --- a/app/[locale]/continent/[slug]/page.tsx +++ /dev/null @@ -1,69 +0,0 @@ -"use client"; - -import { use } from "react"; -import dynamic from "next/dynamic"; -import { useTranslations } from "next-intl"; -import { Navbar } from "@/components/layout/navbar"; -import { ParticleBg } from "@/components/layout/particle-bg"; -import { ViewSwitcher } from "@/components/layout/view-switcher"; -import { StatsPanel } from "@/components/dashboard/stats-panel"; -import { ClawFeed } from "@/components/dashboard/claw-feed"; - -const ContinentMap = dynamic( - () => - import("@/components/map/continent-map").then((m) => ({ - default: m.ContinentMap, - })), - { ssr: false } -); - -const continentSlugs = ["asia", "europe", "americas", "africa", "oceania"] as const; - -interface PageProps { - params: Promise<{ slug: string }>; -} - -export default function ContinentPage({ params }: PageProps) { - const { slug } = use(params); - const t = useTranslations("continents"); - const tPage = useTranslations("continentPage"); - - const name = continentSlugs.includes(slug as (typeof continentSlugs)[number]) - ? t(slug as (typeof continentSlugs)[number]) - : "Unknown"; - - return ( -
- - - -
-
-

- {tPage("regionTitle", { name })} -

- -
- -
- {/* Map */} -
- -
- - {/* Side Panel */} -
- - -
-
-
-
- ); -} diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 329b417..e1d5806 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -1,5 +1,9 @@ "use client"; +import { useState } from "react"; +import dynamic from "next/dynamic"; +import { useTranslations } from "next-intl"; +import { Map } from "lucide-react"; import { Navbar } from "@/components/layout/navbar"; import { InstallBanner } from "@/components/layout/install-banner"; import { ParticleBg } from "@/components/layout/particle-bg"; @@ -8,38 +12,96 @@ import { StatsPanel } from "@/components/dashboard/stats-panel"; import { ActivityTimeline } from "@/components/dashboard/activity-timeline"; import { ClawFeed } from "@/components/dashboard/claw-feed"; import { RegionRanking } from "@/components/dashboard/region-ranking"; +import { cn } from "@/lib/utils"; + +const ContinentMap = dynamic( + () => + import("@/components/map/continent-map").then((m) => ({ + default: m.ContinentMap, + })), + { ssr: false } +); + +const continentSlugs = ["asia", "europe", "americas", "africa", "oceania"] as const; export default function HomePage() { + const [activeContinent, setActiveContinent] = useState("asia"); + const tContinents = useTranslations("continents"); + const tRegion = useTranslations("regionExplorer"); + return (
- +
-
- -
-
- {/* Left Panel */} -
- - + {/* Section 1: Globe + Dashboard */} +
+
+
- - {/* Center - Globe + Timeline */} -
-
- +
+ {/* Left Panel */} +
+ +
- + + {/* Center - Globe + Timeline */} +
+
+ +
+ +
+ + {/* Right Panel */} +
+ +
+
+
+ + {/* Section 2: Region Explorer */} +
+
+

+ + {tRegion("title")} +

- {/* Right Panel */} -
- + {/* Continent Tabs */} +
+ {continentSlugs.map((slug) => ( + + ))}
-
+ {/* Map — explicit height so MapLibre can render */} + +
); diff --git a/components/globe/globe-view.tsx b/components/globe/globe-view.tsx index 716af10..c957a4c 100644 --- a/components/globe/globe-view.tsx +++ b/components/globe/globe-view.tsx @@ -2,8 +2,9 @@ import { useEffect, useRef, useState, useCallback, useMemo } from "react"; import dynamic from "next/dynamic"; -import { useTranslations } from "next-intl"; +import { useTranslations, useLocale } from "next-intl"; import { useHeatmapData, type HeatmapPoint } from "@/hooks/use-heatmap-data"; +import { useCountryData, type LabelData } from "./use-country-data"; import { GlobeControls } from "./globe-controls"; function GlobeLoading() { @@ -34,6 +35,7 @@ interface ArcData { export function GlobeView() { const t = useTranslations("globe"); const tPopup = useTranslations("clawPopup"); + const locale = useLocale(); // eslint-disable-next-line @typescript-eslint/no-explicit-any const globeRef = useRef(undefined); const containerRef = useRef(null); @@ -41,6 +43,7 @@ export function GlobeView() { const [hoveredPoint, setHoveredPoint] = useState(null); const [selectedPoint, setSelectedPoint] = useState(null); const { points } = useHeatmapData(30000); + const { countries, labels } = useCountryData(locale); // Generate arcs only between online points const arcs = useMemo((): ArcData[] => { @@ -117,6 +120,32 @@ export function GlobeView() { globeImageUrl="//unpkg.com/three-globe/example/img/earth-dark.jpg" atmosphereColor="#00f0ff" atmosphereAltitude={0.15} + // Country polygons + polygonsData={countries} + polygonCapColor={() => "rgba(26, 31, 46, 0.6)"} + polygonSideColor={() => "rgba(0, 240, 255, 0.05)"} + polygonStrokeColor={() => "rgba(0, 240, 255, 0.15)"} + polygonAltitude={0.005} + // Country name labels (use HTML elements for CJK support) + htmlElementsData={labels} + htmlLat={(d: object) => (d as LabelData).lat} + htmlLng={(d: object) => (d as LabelData).lng} + htmlAltitude={0.01} + htmlElement={(d: object) => { + const label = d as LabelData; + const el = document.createElement("div"); + el.textContent = label.name; + el.style.color = "rgba(0, 240, 255, 0.5)"; + el.style.fontSize = "10px"; + el.style.fontFamily = "system-ui, -apple-system, sans-serif"; + el.style.pointerEvents = "none"; + el.style.userSelect = "none"; + el.style.whiteSpace = "nowrap"; + el.style.textShadow = "0 0 4px rgba(0, 240, 255, 0.3)"; + return el; + }} + // Graticules + showGraticules={true} // Points pointsData={points} pointLat={(d: object) => (d as HeatmapPoint).lat} diff --git a/components/globe/use-country-data.ts b/components/globe/use-country-data.ts new file mode 100644 index 0000000..0fccb41 --- /dev/null +++ b/components/globe/use-country-data.ts @@ -0,0 +1,53 @@ +import { useState, useEffect, useMemo } from "react"; +import { feature } from "topojson-client"; +import type { Topology, GeometryCollection } from "topojson-specification"; +import type { FeatureCollection, Feature, Geometry } from "geojson"; +import { COUNTRY_LABELS } from "@/lib/geo/country-labels"; + +const TOPOJSON_URL = + "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json"; + +export interface LabelData { + lat: number; + lng: number; + name: string; +} + +export function useCountryData(locale: string) { + const [countries, setCountries] = useState[]>([]); + const [isLoading, setIsLoading] = useState(true); + + useEffect(() => { + let cancelled = false; + + fetch(TOPOJSON_URL) + .then((res) => res.json()) + .then((topo: Topology) => { + if (cancelled) return; + const geo = feature( + topo, + topo.objects.countries as GeometryCollection + ) as FeatureCollection; + setCountries(geo.features); + setIsLoading(false); + }) + .catch(() => { + if (!cancelled) setIsLoading(false); + }); + + return () => { + cancelled = true; + }; + }, []); + + const labels: LabelData[] = useMemo(() => { + const lang = locale === "zh" ? "zh" : "en"; + return COUNTRY_LABELS.map((c) => ({ + lat: c.lat, + lng: c.lng, + name: c[lang], + })); + }, [locale]); + + return { countries, labels, isLoading }; +} diff --git a/components/layout/navbar.tsx b/components/layout/navbar.tsx index 817e903..bf8e6ed 100644 --- a/components/layout/navbar.tsx +++ b/components/layout/navbar.tsx @@ -1,16 +1,11 @@ "use client"; -import { Activity, Globe2, Map } from "lucide-react"; +import { Activity } from "lucide-react"; import { useTranslations } from "next-intl"; import { Link } from "@/i18n/navigation"; -import { cn } from "@/lib/utils"; import { LanguageSwitcher } from "./language-switcher"; -interface NavbarProps { - activeView?: "globe" | "map"; -} - -export function Navbar({ activeView = "globe" }: NavbarProps) { +export function Navbar() { const t = useTranslations("navbar"); return ( @@ -26,33 +21,6 @@ export function Navbar({ activeView = "globe" }: NavbarProps) { -
- - - {t("globe")} - - - - {t("map")} - -
-
diff --git a/components/layout/view-switcher.tsx b/components/layout/view-switcher.tsx deleted file mode 100644 index cbf7ae3..0000000 --- a/components/layout/view-switcher.tsx +++ /dev/null @@ -1,49 +0,0 @@ -"use client"; - -import { Globe2, Map } from "lucide-react"; -import { useTranslations } from "next-intl"; -import { Link } from "@/i18n/navigation"; -import { cn } from "@/lib/utils"; - -const continentSlugs = ["asia", "europe", "americas", "africa", "oceania"] as const; - -interface ViewSwitcherProps { - activeContinent?: string; -} - -export function ViewSwitcher({ activeContinent }: ViewSwitcherProps) { - const tSwitcher = useTranslations("viewSwitcher"); - const tContinents = useTranslations("continents"); - - return ( -
- - - {tSwitcher("global")} - - {continentSlugs.map((slug) => ( - - - {tContinents(slug)} - - ))} -
- ); -} diff --git a/components/map/continent-map.tsx b/components/map/continent-map.tsx index 06434e5..19b2cee 100644 --- a/components/map/continent-map.tsx +++ b/components/map/continent-map.tsx @@ -7,6 +7,7 @@ import type { MapLayerMouseEvent, LngLatLike, MapRef } from "react-map-gl/maplib import type { LayerSpecification } from "maplibre-gl"; import "maplibre-gl/dist/maplibre-gl.css"; import { useHeatmapData, type HeatmapPoint } from "@/hooks/use-heatmap-data"; +import { cn } from "@/lib/utils"; import { MapPopup } from "./map-popup"; const CARTO_STYLE = @@ -88,9 +89,10 @@ const circleLayer: LayerSpecification = { interface ContinentMapProps { slug: string; + className?: string; } -export function ContinentMap({ slug }: ContinentMapProps) { +export function ContinentMap({ slug, className }: ContinentMapProps) { const locale = useLocale(); const config = continentConfigs[slug] ?? continentConfigs.asia; const { points } = useHeatmapData(30000); @@ -162,10 +164,10 @@ export function ContinentMap({ slug }: ContinentMapProps) { ); return ( -
+
=8.0'} + topojson-client@3.1.0: + resolution: {integrity: sha512-605uxS6bcYxGXw9qi62XyrV6Q3xwbndjachmNxu8HWTtVPxZfEJN9fd/SZS1Q54Sn2y0TMyMxFj/cJINqGHrKw==} + hasBin: true + ts-api-utils@2.4.0: resolution: {integrity: sha512-3TaVTaAv2gTiMB35i3FiGJaRfwb3Pyn/j3m/bfAvGe8FB7CF6u+LMYqYlDh7reQf7UNvoTvdfAqHGmPGOSsPmA==} engines: {node: '>=18.12'} @@ -3835,6 +3860,15 @@ snapshots: fflate: 0.8.2 meshoptimizer: 0.18.1 + '@types/topojson-client@3.1.5': + dependencies: + '@types/geojson': 7946.0.16 + '@types/topojson-specification': 1.0.5 + + '@types/topojson-specification@1.0.5': + dependencies: + '@types/geojson': 7946.0.16 + '@types/webxr@0.5.24': {} '@typescript-eslint/eslint-plugin@8.57.0(@typescript-eslint/parser@8.57.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.4(jiti@2.6.1))(typescript@5.9.3)': @@ -4180,6 +4214,8 @@ snapshots: color-name@1.1.4: {} + commander@2.20.3: {} + concat-map@0.0.1: {} cross-spawn@7.0.6: @@ -5926,6 +5962,10 @@ snapshots: dependencies: is-number: 7.0.0 + topojson-client@3.1.0: + dependencies: + commander: 2.20.3 + ts-api-utils@2.4.0(typescript@5.9.3): dependencies: typescript: 5.9.3 diff --git a/skill/openclaw-reporter/SKILL.md b/skill/openclaw-reporter/SKILL.md index 46c9aae..60542f2 100644 --- a/skill/openclaw-reporter/SKILL.md +++ b/skill/openclaw-reporter/SKILL.md @@ -3,11 +3,8 @@ name: openclaw-reporter description: | Opt-in reporter for the OpenClaw global claw heatmap. On first use, ASKS the user for consent before registering. - Sends heartbeats (platform + model only) and generic task summaries to https://kymr.top/. - Heartbeats are sent at session start and renewed via a PostToolUse hook, rate-limited - to at most once per 3 minutes — most invocations exit immediately after a timestamp check. - The PostToolUse hook does NOT read or send any tool names, arguments, or results. - Task reports are sent automatically via a Stop hook when the agent stops responding. + Sends a heartbeat (platform + model only) when the skill is loaded. + Task reports are only sent when the user explicitly mentions completing a task. Data collected: user-chosen claw name, OS platform, model name, generic task category. Credentials: the server returns an apiKey on registration, which is stored locally in ~/.openclaw/config.json and sent as a Bearer token in subsequent requests. @@ -16,12 +13,8 @@ requirements: network: true writeFiles: - "~/.openclaw/config.json" - - "~/.openclaw/scripts/heartbeat.sh" - - "~/.openclaw/scripts/task-report.sh" - - "~/.openclaw/.last_heartbeat" binaries: - curl - - python3 - uname env: - name: CLAUDE_MODEL @@ -31,17 +24,7 @@ hooks: SessionStart: - hooks: - type: command - command: "bash $HOME/.openclaw/scripts/heartbeat.sh 2>/dev/null || true" - timeout: 10 - PostToolUse: - - hooks: - - type: command - command: "bash $HOME/.openclaw/scripts/heartbeat.sh 2>/dev/null || true" - timeout: 5 - Stop: - - hooks: - - type: command - command: "bash $HOME/.openclaw/scripts/task-report.sh 2>/dev/null || true" + command: "CONFIG=\"$HOME/.openclaw/config.json\"; [ -f \"$CONFIG\" ] && KEY=$(grep -o '\"apiKey\"[[:space:]]*:[[:space:]]*\"[^\"]*\"' \"$CONFIG\" | head -1 | sed 's/.*\"\\([^\"]*\\)\"$/\\1/') && [ -n \"$KEY\" ] && curl -s -o /dev/null --max-time 5 -X POST 'https://kymr.top/api/v1/heartbeat' -H 'Content-Type: application/json' -H \"Authorization: Bearer $KEY\" -d \"{\\\"platform\\\":\\\"$(uname -s | tr '[:upper:]' '[:lower:]')\\\",\\\"model\\\":\\\"${CLAUDE_MODEL:-unknown}\\\"}\" 2>/dev/null || true" timeout: 10 --- @@ -51,10 +34,9 @@ This skill lets you participate in the OpenClaw global claw activity heatmap. It ## How It Works -- **Heartbeat**: Sent at session start (`SessionStart` hook) and renewed periodically (`PostToolUse` hook, rate-limited to once per 3 minutes). The `PostToolUse` hook does **not** read tool names, arguments, or results — it only triggers the same timestamp-checked heartbeat script. Most invocations exit immediately after reading a single timestamp file. -- **Task report**: Sent automatically when the agent finishes responding via a `Stop` hook. +- **Heartbeat**: Sent once when the skill is loaded (`SessionStart` hook). No other automated hooks are used — no `PostToolUse`, no `Stop` hooks. +- **Task report**: Sent **only** when the user explicitly mentions completing a task or asks for a report. The agent calls the task API directly — no automated scripts. - **Registration**: One-time setup requiring explicit user consent (see below). -- **Hooks**: Hooks are registered in the skill frontmatter and activate when the skill is loaded. No system-level files are modified. ## Data Disclosure @@ -67,15 +49,15 @@ This skill sends the following data to `https://kymr.top/` (the OpenClaw Market | Model | `claude-sonnet-4-6` | Model usage stats | | Task summary | `"Completed a task"` | Generic activity indicator | -**Stored locally:** Registration returns an `apiKey` from the server, saved in `~/.openclaw/config.json` with `chmod 600` (owner-only access). This token is sent as `Authorization: Bearer` header in heartbeat and task report requests. The endpoint URL (`https://kymr.top/`) is hardcoded in hook scripts — not read from the config file — so a modified config cannot redirect telemetry. The `CLAUDE_MODEL` environment variable is read (if available) to identify the active model — it falls back to `"unknown"` if not set. +**Stored locally:** Registration returns an `apiKey` from the server, saved in `~/.openclaw/config.json` with `chmod 600` (owner-only access). The endpoint URL (`https://kymr.top/`) is hardcoded — not read from the config file — so a modified config cannot redirect telemetry. -**Visible to the server:** Your IP address is visible on every HTTPS request (this is inherent to any network call and not specific to this skill). The server uses IP for approximate geolocation on the heatmap — no more precise than city-level. +**Visible to the server:** Your IP address is visible on every HTTPS request (inherent to any network call). The server uses IP for approximate geolocation on the heatmap — no more precise than city-level. **Never sent:** system usernames, file paths, code snippets, project names, tool names, tool arguments, tool results, or secrets. ## Configuration -Config is stored at `~/.openclaw/config.json` (permissions `600`). Hook scripts live at `~/.openclaw/scripts/`. The hooks check for the config file before sending any requests — if it doesn't exist, nothing is sent. The endpoint is hardcoded to `https://kymr.top/` in the scripts and is **not** configurable via the config file. +Config is stored at `~/.openclaw/config.json` (permissions `600`). No external scripts are deployed — the heartbeat is sent inline via the `SessionStart` hook command. ## First-Time Setup (Requires User Consent) @@ -85,7 +67,7 @@ If `~/.openclaw/config.json` does not exist, follow these steps: Use the AskUserQuestion tool: -- Question: "OpenClaw Reporter wants to register a claw name and send periodic heartbeats (once per 3 min, platform + model only) to https://kymr.top/ for the global heatmap. The server will issue an API key stored locally at ~/.openclaw/config.json. No file paths, code, tool names, or project data is sent. Allow?" +- Question: "OpenClaw Reporter wants to register a claw name and send a heartbeat (platform + model only) to https://kymr.top/ when the skill loads. Task reports are only sent when you explicitly mention completing a task. The server will issue an API key stored locally at ~/.openclaw/config.json. No file paths, code, tool names, or project data is sent. Allow?" - Options: "Yes, register" / "No, skip" **If the user selects "No, skip":** do NOT register and do NOT ask again in this session. Stop here. @@ -94,135 +76,89 @@ Use the AskUserQuestion tool: If the user consented, use AskUserQuestion again: -- Question: "Pick a name for your claw on the heatmap! (e.g. CoolClaw, NightCrawler, CodeClaw)" +- Question: "Pick a name for your claw on the heatmap! (1-30 chars, letters/numbers/hyphens/underscores only, e.g. CoolClaw, NightCrawler, CodeClaw)" - Let the user type a custom name via the "Other" option (no preset options needed, but provide a few fun suggestions as options) - Options: "CoolClaw" / "CodeClaw" / "NightCrawler" Use whatever the user provides as the claw name. -### Step 3: Register and install hooks +### Step 3: Register and save config -After receiving the name (stored as `CLAW_NAME`), run Step 3a and Step 3b in sequence. - -#### Step 3a: Register and save config +After receiving the name (stored as `CLAW_NAME`), run the following: ```bash # --- OpenClaw Registration --- set -e OPENCLAW_ENDPOINT="https://kymr.top" -export CLAW_NAME="USER_CHOSEN_NAME_HERE" +CLAW_NAME="USER_CHOSEN_NAME_HERE" -mkdir -p ~/.openclaw/scripts +# Validate claw name: only allow alphanumeric, hyphens, underscores (1-30 chars). +# This whitelist ensures $CLAW_NAME is safe for shell interpolation and JSON embedding. +if ! echo "$CLAW_NAME" | grep -qE '^[A-Za-z0-9_-]{1,30}$'; then + echo "Error: Claw name must be 1-30 characters, alphanumeric/hyphens/underscores only." + exit 1 +fi + +mkdir -p ~/.openclaw # Register with the server +# Safe: CLAW_NAME is validated above to contain only [A-Za-z0-9_-] RESPONSE=$(curl -s -X POST "$OPENCLAW_ENDPOINT/api/v1/register" \ -H "Content-Type: application/json" \ -d "{ \"name\": \"$CLAW_NAME\", \"platform\": \"$(uname -s | tr '[:upper:]' '[:lower:]')\", - \"model\": \"$(echo $CLAUDE_MODEL 2>/dev/null || echo 'unknown')\" + \"model\": \"${CLAUDE_MODEL:-unknown}\" }") -# Save config — pipe response via stdin to avoid shell injection -# Creates ~/.openclaw/config.json with chmod 600 (owner-only access) -echo "$RESPONSE" | python3 -c " -import json, sys, os -data = json.loads(sys.stdin.read()) -config = { - 'clawId': data.get('clawId', ''), - 'apiKey': data.get('apiKey', ''), - 'name': os.environ.get('CLAW_NAME', '') +# Extract fields from JSON response using grep/sed (no python3 needed) +CLAW_ID=$(echo "$RESPONSE" | grep -o '"clawId"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/') +API_KEY=$(echo "$RESPONSE" | grep -o '"apiKey"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/') + +if [ -z "$API_KEY" ]; then + echo "Error: Registration failed. Server response: $RESPONSE" + exit 1 +fi + +# Write config file +cat > ~/.openclaw/config.json << CFGEOF +{ + "clawId": "$CLAW_ID", + "apiKey": "$API_KEY", + "name": "$CLAW_NAME" } -path = os.path.expanduser('~/.openclaw/config.json') -with open(path, 'w') as f: - json.dump(config, f, indent=2) -os.chmod(path, 0o600) -print('Registered as:', config['name']) -" +CFGEOF +chmod 600 ~/.openclaw/config.json + +echo "Registered as: $CLAW_NAME" ``` -#### Step 3b: Deploy hook scripts +## Task Reporting (Manual Only) + +Task reports are **never sent automatically**. Only send a task report when the user explicitly mentions completing a task, finishing work, or asks to report activity. + +When triggered, run: ```bash -# --- Deploy heartbeat script (rate-limited to once per 180s) --- -cat > ~/.openclaw/scripts/heartbeat.sh << 'HOOKEOF' -#!/bin/bash -# OpenClaw heartbeat — rate-limited to once per 180 seconds. -# No tool names, arguments, or results are read or sent. CONFIG="$HOME/.openclaw/config.json" -[ -f "$CONFIG" ] || exit 0 -LAST_FILE="$HOME/.openclaw/.last_heartbeat" -NOW=$(date +%s) -if [ -f "$LAST_FILE" ]; then - LAST=$(cat "$LAST_FILE" 2>/dev/null || echo 0) - [ $((NOW - LAST)) -lt 180 ] && exit 0 -fi -KEY=$(python3 -c "import json; print(json.load(open('$CONFIG'))['apiKey'])" 2>/dev/null) || exit 0 -[ -z "$KEY" ] && exit 0 -curl -s -o /dev/null --max-time 5 -X POST 'https://kymr.top/api/v1/heartbeat' \ - -H 'Content-Type: application/json' \ - -H "Authorization: Bearer $KEY" \ - -d "{\"platform\":\"$(uname -s | tr '[:upper:]' '[:lower:]')\",\"model\":\"${CLAUDE_MODEL:-unknown}\"}" \ - 2>/dev/null && echo "$NOW" > "$LAST_FILE" || true -HOOKEOF -chmod +x ~/.openclaw/scripts/heartbeat.sh - -# --- Deploy task report script --- -cat > ~/.openclaw/scripts/task-report.sh << 'HOOKEOF' -#!/bin/bash -CONFIG="$HOME/.openclaw/config.json" -[ -f "$CONFIG" ] || exit 0 -KEY=$(python3 -c "import json; print(json.load(open('$CONFIG'))['apiKey'])" 2>/dev/null) || exit 0 -[ -z "$KEY" ] && exit 0 +[ -f "$CONFIG" ] || { echo "OpenClaw not registered."; exit 0; } +KEY=$(grep -o '"apiKey"[[:space:]]*:[[:space:]]*"[^"]*"' "$CONFIG" | head -1 | sed 's/.*"\([^"]*\)"$/\1/') +[ -z "$KEY" ] && { echo "No API key found."; exit 0; } curl -s -o /dev/null --max-time 5 -X POST 'https://kymr.top/api/v1/task' \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $KEY" \ - -d "{\"summary\":\"Completed a task\",\"model\":\"${CLAUDE_MODEL:-unknown}\"}" 2>/dev/null || true -HOOKEOF -chmod +x ~/.openclaw/scripts/task-report.sh - -echo "--- OpenClaw setup complete ---" + -d "{\"summary\":\"Completed a task\",\"model\":\"${CLAUDE_MODEL:-unknown}\"}" 2>/dev/null \ + && echo "Task reported." || echo "Task report failed (non-blocking)." ``` -## Hook Verification (Auto-Repair) - -**Every time this skill is loaded**, if `~/.openclaw/config.json` exists, verify that hook scripts are present. Run this check silently: - -1. Check `~/.openclaw/scripts/heartbeat.sh` exists and is executable -2. Check `~/.openclaw/scripts/task-report.sh` exists and is executable - -If **any** check fails, re-run Step 3b from the registration above to redeploy the scripts. Do this silently without asking the user. - -Verification command (run silently on skill load when config exists): - -```bash -# Quick hook health check — re-deploy scripts if missing -if [ -f ~/.openclaw/config.json ]; then - NEEDS_REPAIR=false - [ -x ~/.openclaw/scripts/heartbeat.sh ] || NEEDS_REPAIR=true - [ -x ~/.openclaw/scripts/task-report.sh ] || NEEDS_REPAIR=true - - if [ "$NEEDS_REPAIR" = true ]; then - echo "OpenClaw hook scripts need repair — reinstalling..." - # (re-run Step 3b from registration above) - fi -fi -``` - -If repair is needed, re-run Step 3b (Deploy hook scripts) from the registration above. - ## Opt-Out / Unregister -To stop all OpenClaw reporting and remove hooks: +To stop all OpenClaw reporting: ```bash -# Remove scripts, config, and timestamp -rm -f ~/.openclaw/scripts/heartbeat.sh ~/.openclaw/scripts/task-report.sh -rmdir ~/.openclaw/scripts 2>/dev/null -rm -f ~/.openclaw/config.json ~/.openclaw/.last_heartbeat +rm -f ~/.openclaw/config.json rmdir ~/.openclaw 2>/dev/null - echo "OpenClaw fully uninstalled." ``` @@ -232,9 +168,9 @@ After deletion, no heartbeats or task reports will be sent. The skill will ask f 1. **User consent is REQUIRED** before first registration — never register silently 2. If the user declines registration, respect the decision and do not ask again in the same session -3. Hooks run automatically via skill frontmatter — do NOT manually execute heartbeat or task report commands -4. If any OpenClaw request fails, continue normally — never interrupt the user's workflow -5. Never include identifying information in task summaries -6. **On skill load**: if `~/.openclaw/config.json` exists, silently verify hook scripts are present and redeploy if missing -7. **Idempotent**: running script deployment multiple times is safe +3. Heartbeat is sent automatically via the `SessionStart` hook when the skill is loaded — this is the ONLY automated action +4. **Task reports are manual only** — only send when the user explicitly mentions completing a task or asks to report +5. If any OpenClaw request fails, continue normally — never interrupt the user's workflow +6. Never include identifying information in task summaries +7. **No external scripts**: all logic is inline or executed by the agent directly 8. **No system-level modifications**: never write to `~/.claude/settings.json` or any file outside `~/.openclaw/` diff --git a/skill/openclaw-reporter/scripts/heartbeat.sh b/skill/openclaw-reporter/scripts/heartbeat.sh deleted file mode 100755 index 99b6ec8..0000000 --- a/skill/openclaw-reporter/scripts/heartbeat.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# OpenClaw heartbeat — sends platform + model to heatmap server. -# Rate-limited: sends at most once per 180 seconds. -# Called by both SessionStart and PostToolUse hooks. -# No tool names, arguments, or results are read or sent. - -CONFIG="$HOME/.openclaw/config.json" -[ -f "$CONFIG" ] || exit 0 - -# --- Rate limit check (fast path: exit in <1ms) --- -LAST_FILE="$HOME/.openclaw/.last_heartbeat" -NOW=$(date +%s) -if [ -f "$LAST_FILE" ]; then - LAST=$(cat "$LAST_FILE" 2>/dev/null || echo 0) - [ $((NOW - LAST)) -lt 180 ] && exit 0 -fi - -# --- Send heartbeat --- -KEY=$(python3 -c "import json; print(json.load(open('$CONFIG'))['apiKey'])" 2>/dev/null) || exit 0 -[ -z "$KEY" ] && exit 0 - -curl -s -o /dev/null --max-time 5 -X POST 'https://kymr.top/api/v1/heartbeat' \ - -H 'Content-Type: application/json' \ - -H "Authorization: Bearer $KEY" \ - -d "{\"platform\":\"$(uname -s | tr '[:upper:]' '[:lower:]')\",\"model\":\"${CLAUDE_MODEL:-unknown}\"}" \ - 2>/dev/null && echo "$NOW" > "$LAST_FILE" || true diff --git a/skill/openclaw-reporter/scripts/task-report.sh b/skill/openclaw-reporter/scripts/task-report.sh deleted file mode 100755 index b6e9393..0000000 --- a/skill/openclaw-reporter/scripts/task-report.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# OpenClaw task report — Stop hook -# Sends a generic task completion signal. Fails silently. - -CONFIG="$HOME/.openclaw/config.json" -[ -f "$CONFIG" ] || exit 0 - -KEY=$(python3 -c "import json; print(json.load(open('$CONFIG'))['apiKey'])" 2>/dev/null) || exit 0 -[ -z "$KEY" ] && exit 0 - -curl -s -o /dev/null --max-time 5 -X POST 'https://kymr.top/api/v1/task' \ - -H 'Content-Type: application/json' \ - -H "Authorization: Bearer $KEY" \ - -d "{\"summary\":\"Completed a task\",\"model\":\"${CLAUDE_MODEL:-unknown}\"}" 2>/dev/null || true