Add CustomMessageEntry rendering infrastructure
- Add renderCustomMessage to HookAPI for registering custom renderers - Add CustomMessageRenderer type and CustomMessageRenderOptions - Store customMessageRenderers in LoadedHook - Add getCustomMessageRenderer(customType) to HookRunner - SessionContext.entries now aligned with messages (same length, corresponding indices) TUI can now correlate messages with their source entries to identify custom_message entries and use hook-provided renderers.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import type { LoadedHook, SendHandler } from "./loader.js";
|
||||
import type {
|
||||
CustomMessageRenderer,
|
||||
ExecOptions,
|
||||
ExecResult,
|
||||
HookError,
|
||||
@@ -203,6 +204,20 @@ export class HookRunner {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a custom message renderer for the given customType.
|
||||
* Returns the first renderer found across all hooks, or undefined if none.
|
||||
*/
|
||||
getCustomMessageRenderer(customType: string): CustomMessageRenderer | undefined {
|
||||
for (const hook of this.hooks) {
|
||||
const renderer = hook.customMessageRenderers.get(customType);
|
||||
if (renderer) {
|
||||
return renderer;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the event context for handlers.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user