docs(agent-hooks): describe header merge envelope

This commit is contained in:
MarkXian
2026-08-07 10:51:43 +08:00
parent 321672c578
commit 9cd64e191b
+8
View File
@@ -533,6 +533,14 @@ function readHookHeader(headers: IncomingHttpHeaders, name: string): string | un
return Array.isArray(value) ? value[0] : value
}
/**
* Wraps a JSON hook payload with Orca metadata carried in transport headers.
*
* POSIX hook scripts post the agent payload as JSON and send pane/session
* identity in headers, while older callers may still post the historical
* `{ paneKey, payload }` envelope. Returning a marked envelope lets downstream
* normalization share one code path without double-wrapping legacy requests.
*/
export function mergeAgentHookRequestHeaders(body: unknown, headers: IncomingHttpHeaders): unknown {
const paneKey = readHookHeader(headers, 'x-orca-pane-key')
if (!paneKey) {