feat(coding-agent): expose streamingBehavior on InputEvent
Add streamingBehavior to InputEvent so extensions can distinguish idle prompts from mid-stream steers and queued follow-ups. - Add streamingBehavior field to InputEvent type - Thread it through ExtensionRunner.emitInput() and AgentSession.prompt() - Add streaming-aware input gate example with tests - Document in extensions.md
This commit is contained in:
@@ -1036,7 +1036,12 @@ export class ExtensionRunner {
|
||||
}
|
||||
|
||||
/** Emit input event. Transforms chain, "handled" short-circuits. */
|
||||
async emitInput(text: string, images: ImageContent[] | undefined, source: InputSource): Promise<InputEventResult> {
|
||||
async emitInput(
|
||||
text: string,
|
||||
images: ImageContent[] | undefined,
|
||||
source: InputSource,
|
||||
streamingBehavior?: "steer" | "followUp",
|
||||
): Promise<InputEventResult> {
|
||||
const ctx = this.createContext();
|
||||
let currentText = text;
|
||||
let currentImages = images;
|
||||
@@ -1044,7 +1049,13 @@ export class ExtensionRunner {
|
||||
for (const ext of this.extensions) {
|
||||
for (const handler of ext.handlers.get("input") ?? []) {
|
||||
try {
|
||||
const event: InputEvent = { type: "input", text: currentText, images: currentImages, source };
|
||||
const event: InputEvent = {
|
||||
type: "input",
|
||||
text: currentText,
|
||||
images: currentImages,
|
||||
source,
|
||||
streamingBehavior,
|
||||
};
|
||||
const result = (await handler(event, ctx)) as InputEventResult | undefined;
|
||||
if (result?.action === "handled") return result;
|
||||
if (result?.action === "transform") {
|
||||
|
||||
@@ -756,6 +756,8 @@ export interface InputEvent {
|
||||
images?: ImageContent[];
|
||||
/** Where the input came from */
|
||||
source: InputSource;
|
||||
/** How the input will be delivered during streaming, or undefined when idle */
|
||||
streamingBehavior?: "steer" | "followUp";
|
||||
}
|
||||
|
||||
/** Result from input event handler */
|
||||
|
||||
Reference in New Issue
Block a user