Add agent state methods to CustomToolContext and fix abort signature
CustomToolContext now has: - isIdle() - check if agent is streaming - hasQueuedMessages() - check if user has queued messages - abort() - abort current operation (fire-and-forget) Changed abort() signature from Promise<void> to void in both HookContext and CustomToolContext. The abort is fire-and-forget: it calls session.abort() without awaiting, so the abort signal is set immediately while waitForIdle() runs in the background. Fixes #388
This commit is contained in:
@@ -47,6 +47,12 @@ export interface CustomToolContext {
|
||||
modelRegistry: ModelRegistry;
|
||||
/** Current model (may be undefined if no model is selected yet) */
|
||||
model: Model<any> | undefined;
|
||||
/** Whether the agent is idle (not streaming) */
|
||||
isIdle(): boolean;
|
||||
/** Whether there are queued messages waiting to be processed */
|
||||
hasQueuedMessages(): boolean;
|
||||
/** Abort the current agent operation (fire-and-forget, does not wait) */
|
||||
abort(): void;
|
||||
}
|
||||
|
||||
/** Session event passed to onSession callback */
|
||||
|
||||
Reference in New Issue
Block a user