mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 13:04:08 +00:00
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:
parent
3ecaaa5937
commit
11a7845ceb
7 changed files with 83 additions and 10 deletions
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue