mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 05:00:16 +00:00
Rename immediate -> allowDuringStreaming for hook commands
This commit is contained in:
parent
454dd919be
commit
f8352bb7d7
4 changed files with 15 additions and 7 deletions
|
|
@ -29,6 +29,14 @@ export default function (pi: HookAPI) {
|
||||||
return box;
|
return box;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pi.registerCommand("no-stream", {
|
||||||
|
description: "Send a message without streaming",
|
||||||
|
handler: async (ctx) => {
|
||||||
|
ctx.ui.notify("Sending message after streaming is done...");
|
||||||
|
},
|
||||||
|
allowDuringStreaming: true,
|
||||||
|
})
|
||||||
|
|
||||||
// Register /test-msg command
|
// Register /test-msg command
|
||||||
pi.registerCommand("test-msg", {
|
pi.registerCommand("test-msg", {
|
||||||
description: "Send a test custom message",
|
description: "Send a test custom message",
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ const SNAKE_SAVE_TYPE = "snake-save";
|
||||||
export default function (pi: HookAPI) {
|
export default function (pi: HookAPI) {
|
||||||
pi.registerCommand("snake", {
|
pi.registerCommand("snake", {
|
||||||
description: "Play Snake!",
|
description: "Play Snake!",
|
||||||
immediate: true, // Run immediately, even during streaming
|
allowDuringStreaming: true, // Run even during streaming, not queued
|
||||||
handler: async (ctx) => {
|
handler: async (ctx) => {
|
||||||
if (!ctx.hasUI) {
|
if (!ctx.hasUI) {
|
||||||
ctx.ui.notify("Snake requires interactive mode", "error");
|
ctx.ui.notify("Snake requires interactive mode", "error");
|
||||||
|
|
|
||||||
|
|
@ -442,8 +442,8 @@ export interface HookCommandContext {
|
||||||
export interface RegisteredCommand {
|
export interface RegisteredCommand {
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
/** If true, command runs immediately even during streaming (doesn't get queued) */
|
/** If true, command runs during streaming instead of being queued */
|
||||||
immediate?: boolean;
|
allowDuringStreaming?: boolean;
|
||||||
handler: (ctx: HookCommandContext) => Promise<void>;
|
handler: (ctx: HookCommandContext) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -529,7 +529,7 @@ export interface HookAPI {
|
||||||
*/
|
*/
|
||||||
registerCommand(
|
registerCommand(
|
||||||
name: string,
|
name: string,
|
||||||
options: { description?: string; immediate?: boolean; handler: RegisteredCommand["handler"] },
|
options: { description?: string; allowDuringStreaming?: boolean; handler: RegisteredCommand["handler"] },
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -744,13 +744,13 @@ export class InteractiveMode {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this is an immediate hook command (runs even during streaming)
|
// Check if this hook command can run during streaming (not queued)
|
||||||
if (text.startsWith("/") && this.session.hookRunner && this.session.isStreaming) {
|
if (text.startsWith("/") && this.session.hookRunner && this.session.isStreaming) {
|
||||||
const spaceIndex = text.indexOf(" ");
|
const spaceIndex = text.indexOf(" ");
|
||||||
const commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);
|
const commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);
|
||||||
const command = this.session.hookRunner.getCommand(commandName);
|
const command = this.session.hookRunner.getCommand(commandName);
|
||||||
if (command?.immediate) {
|
if (command?.allowDuringStreaming) {
|
||||||
// Execute immediate hook command right away
|
// Execute hook command right away
|
||||||
this.editor.addToHistory(text);
|
this.editor.addToHistory(text);
|
||||||
this.editor.setText("");
|
this.editor.setText("");
|
||||||
await this.session.prompt(text);
|
await this.session.prompt(text);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue