mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 09:01:14 +00:00
- Rename HookAppMessage to HookMessage, isHookAppMessage to isHookMessage - Remove entries array from SessionContext (use isHookMessage type guard instead) - HookMessage.content now accepts string directly (not just array) - Fix streamMessage type in AgentState (AppMessage, not Message) - Rename CustomMessageComponent to HookMessageComponent - Fix test hook to use pi.sendMessage
24 lines
615 B
TypeScript
24 lines
615 B
TypeScript
/**
|
|
* Test hook that registers a /greet command.
|
|
* Usage: /greet [name]
|
|
*/
|
|
import type { HookAPI } from "@mariozechner/pi-coding-agent/hooks";
|
|
|
|
export default function (pi: HookAPI) {
|
|
pi.registerCommand("greet", {
|
|
description: "Send a greeting message to the LLM",
|
|
handler: async (ctx) => {
|
|
const name = ctx.args.trim() || "world";
|
|
|
|
// Insert a custom message and trigger LLM response
|
|
pi.sendMessage(
|
|
{
|
|
customType: "greeting",
|
|
content: `Hello, ${name}! Please say something nice about them.`,
|
|
display: true,
|
|
},
|
|
true, // triggerTurn - get LLM to respond
|
|
);
|
|
},
|
|
});
|
|
}
|