@@ -185,6 +185,7 @@ export interface AgentSessionConfig {
|
||||
export interface ExtensionBindings {
|
||||
uiContext?: ExtensionUIContext;
|
||||
commandContextActions?: ExtensionCommandContextActions;
|
||||
abortHandler?: () => void;
|
||||
shutdownHandler?: ShutdownHandler;
|
||||
onError?: ExtensionErrorListener;
|
||||
}
|
||||
@@ -296,6 +297,7 @@ export class AgentSession {
|
||||
private _sessionStartEvent: SessionStartEvent;
|
||||
private _extensionUIContext?: ExtensionUIContext;
|
||||
private _extensionCommandContextActions?: ExtensionCommandContextActions;
|
||||
private _extensionAbortHandler?: () => void;
|
||||
private _extensionShutdownHandler?: ShutdownHandler;
|
||||
private _extensionErrorListener?: ExtensionErrorListener;
|
||||
private _extensionErrorUnsubscriber?: () => void;
|
||||
@@ -2042,6 +2044,9 @@ export class AgentSession {
|
||||
if (bindings.commandContextActions !== undefined) {
|
||||
this._extensionCommandContextActions = bindings.commandContextActions;
|
||||
}
|
||||
if (bindings.abortHandler !== undefined) {
|
||||
this._extensionAbortHandler = bindings.abortHandler;
|
||||
}
|
||||
if (bindings.shutdownHandler !== undefined) {
|
||||
this._extensionShutdownHandler = bindings.shutdownHandler;
|
||||
}
|
||||
@@ -2206,7 +2211,13 @@ export class AgentSession {
|
||||
getModel: () => this.model,
|
||||
isIdle: () => !this.isStreaming,
|
||||
getSignal: () => this.agent.signal,
|
||||
abort: () => this.abort(),
|
||||
abort: () => {
|
||||
if (this._extensionAbortHandler) {
|
||||
this._extensionAbortHandler();
|
||||
return;
|
||||
}
|
||||
void this.abort();
|
||||
},
|
||||
hasPendingMessages: () => this.pendingMessageCount > 0,
|
||||
shutdown: () => {
|
||||
this._extensionShutdownHandler?.();
|
||||
|
||||
@@ -1478,6 +1478,9 @@ export class InteractiveMode {
|
||||
const uiContext = this.createExtensionUIContext();
|
||||
await this.session.bindExtensions({
|
||||
uiContext,
|
||||
abortHandler: () => {
|
||||
this.restoreQueuedMessagesToEditor({ abort: true });
|
||||
},
|
||||
commandContextActions: {
|
||||
waitForIdle: () => this.session.agent.waitForIdle(),
|
||||
newSession: async (options) => {
|
||||
@@ -1627,7 +1630,9 @@ export class InteractiveMode {
|
||||
model: this.session.model,
|
||||
isIdle: () => !this.session.isStreaming,
|
||||
signal: this.session.agent.signal,
|
||||
abort: () => this.session.abort(),
|
||||
abort: () => {
|
||||
this.restoreQueuedMessagesToEditor({ abort: true });
|
||||
},
|
||||
hasPendingMessages: () => this.session.pendingMessageCount > 0,
|
||||
shutdown: () => {
|
||||
this.shutdownRequested = true;
|
||||
|
||||
Reference in New Issue
Block a user