mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 04:01:56 +00:00
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:
parent
0d9fddec1e
commit
03159d2f4b
10 changed files with 68 additions and 9 deletions
|
|
@ -476,7 +476,9 @@ export class InteractiveMode {
|
|||
},
|
||||
isIdle: () => !this.session.isStreaming,
|
||||
waitForIdle: () => this.session.agent.waitForIdle(),
|
||||
abort: () => this.session.abort(),
|
||||
abort: () => {
|
||||
this.session.abort();
|
||||
},
|
||||
hasQueuedMessages: () => this.session.queuedMessageCount > 0,
|
||||
uiContext,
|
||||
hasUI: true,
|
||||
|
|
@ -512,6 +514,11 @@ export class InteractiveMode {
|
|||
sessionManager: this.session.sessionManager,
|
||||
modelRegistry: this.session.modelRegistry,
|
||||
model: this.session.model,
|
||||
isIdle: () => !this.session.isStreaming,
|
||||
hasQueuedMessages: () => this.session.queuedMessageCount > 0,
|
||||
abort: () => {
|
||||
this.session.abort();
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
this.showToolError(tool.name, err instanceof Error ? err.message : String(err));
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ export async function runPrintMode(
|
|||
sessionManager: session.sessionManager,
|
||||
modelRegistry: session.modelRegistry,
|
||||
model: session.model,
|
||||
isIdle: () => !session.isStreaming,
|
||||
hasQueuedMessages: () => session.queuedMessageCount > 0,
|
||||
abort: () => {
|
||||
session.abort();
|
||||
},
|
||||
},
|
||||
);
|
||||
} catch (_err) {
|
||||
|
|
|
|||
|
|
@ -196,6 +196,11 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
|||
sessionManager: session.sessionManager,
|
||||
modelRegistry: session.modelRegistry,
|
||||
model: session.model,
|
||||
isIdle: () => !session.isStreaming,
|
||||
hasQueuedMessages: () => session.queuedMessageCount > 0,
|
||||
abort: () => {
|
||||
session.abort();
|
||||
},
|
||||
},
|
||||
);
|
||||
} catch (_err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue