adc62957a7
CI / Multi-repo Path Gate (AST-grep) (windows-latest) (push) Has been cancelled
CI / Version Consistency Check (push) Has been cancelled
CI / npm pack + install test (push) Has been cancelled
CI / Lint & Type Check (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Test (Windows path suite) (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / No Committed Build Artifacts (push) Has been cancelled
CI / Multi-repo Path Gate (AST-grep) (ubuntu-latest) (push) Has been cancelled
Upgrade Test / omc update + session-start hook (push) Has been cancelled
3.6 KiB
3.6 KiB
OpenClaw / Clawhip Routing Contract
This document defines the normalized event contract OMC emits through the OpenClaw bridge for native Clawhip-style consumers.
Goals
- Keep the raw hook event (
event) for backward compatibility. - Add a normalized
signalobject for routing and dedupe-friendly filtering. - Make command/native gateways receive the same logical payload shape as HTTP gateways.
Payload shape
HTTP gateways receive JSON with this structure:
{
"event": "post-tool-use",
"instruction": "...",
"timestamp": "2026-03-09T00:00:00.000Z",
"sessionId": "...",
"projectPath": "...",
"projectName": "...",
"tmuxSession": "...",
"tmuxTail": "...",
"signal": {
"kind": "test",
"name": "test-run",
"phase": "failed",
"routeKey": "test.failed",
"priority": "high",
"toolName": "Bash",
"command": "pnpm test",
"testRunner": "package-test",
"summary": "FAIL src/example.test.ts | ..."
},
"context": {
"sessionId": "...",
"projectPath": "...",
"toolName": "Bash"
}
}
signal contract
| Field | Meaning |
|---|---|
kind |
Routing family: session, tool, test, pull-request, question, keyword |
name |
Stable logical signal name |
phase |
Lifecycle phase: started, finished, failed, idle, detected, requested |
routeKey |
Canonical routing key for downstream consumers |
priority |
high for operational signals, low for generic tool noise |
Additional fields may appear when applicable:
toolNamecommandtestRunnerprUrlsummary
Native command gateway contract
Command gateways now get the same normalized payload through both:
- template variable:
{{payloadJson}} - env var:
OPENCLAW_PAYLOAD_JSON
They also receive convenience env vars:
OPENCLAW_SIGNAL_ROUTE_KEYOPENCLAW_SIGNAL_PHASEOPENCLAW_SIGNAL_KIND
That lets native Clawhip routing consume one contract whether the transport is HTTP or shell-command based.
Current high-priority route keys
session.startedsession.finishedsession.idlequestion.requestedtest.startedtest.finishedtest.failedpull-request.startedpull-request.createdpull-request.failedtool.failed
Generic tool.started / tool.finished remain available as low-priority fallback signals.
Noise reduction
AskUserQuestionnow emits only the dedicatedquestion.requestedsignal instead of also emitting generic tool lifecycle events.- OpenClaw now collapses repeated attached-tmux lifecycle bursts before dispatching them to downstream native gateways.
session-startcollapses on{projectPath, tmuxSession}for a short burst window.keyword-detector(theUserPromptSubmitbridge surface) collapses prompt-submitted bursts on{projectPath, tmuxSession, normalized prompt}.stop/session-endcollapse on{projectPath, tmuxSession}for a short burst window.
- Consumers should prefer
signal.priority === "high"or explicitsignal.routeKeyfilters instead of routing directly on raw hook names.
Stability notes
- Raw
eventnames are preserved for backward compatibility. signalis the preferred routing surface for new native Clawhip integrations.contextremains a whitelisted subset; internal raw tool input/output are used only to derive normalized signals and are not forwarded inpayload.context.