Add extension mode context
This commit is contained in:
@@ -56,6 +56,7 @@ import {
|
||||
type ContextUsage,
|
||||
type ExtensionCommandContextActions,
|
||||
type ExtensionErrorListener,
|
||||
type ExtensionMode,
|
||||
ExtensionRunner,
|
||||
type ExtensionUIContext,
|
||||
type InputSource,
|
||||
@@ -187,6 +188,7 @@ export interface AgentSessionConfig {
|
||||
|
||||
export interface ExtensionBindings {
|
||||
uiContext?: ExtensionUIContext;
|
||||
mode?: ExtensionMode;
|
||||
commandContextActions?: ExtensionCommandContextActions;
|
||||
abortHandler?: () => void;
|
||||
shutdownHandler?: ShutdownHandler;
|
||||
@@ -300,6 +302,7 @@ export class AgentSession {
|
||||
private _baseToolsOverride?: Record<string, AgentTool>;
|
||||
private _sessionStartEvent: SessionStartEvent;
|
||||
private _extensionUIContext?: ExtensionUIContext;
|
||||
private _extensionMode: ExtensionMode = "print";
|
||||
private _extensionCommandContextActions?: ExtensionCommandContextActions;
|
||||
private _extensionAbortHandler?: () => void;
|
||||
private _extensionShutdownHandler?: ShutdownHandler;
|
||||
@@ -2064,6 +2067,9 @@ export class AgentSession {
|
||||
if (bindings.uiContext !== undefined) {
|
||||
this._extensionUIContext = bindings.uiContext;
|
||||
}
|
||||
if (bindings.mode !== undefined) {
|
||||
this._extensionMode = bindings.mode;
|
||||
}
|
||||
if (bindings.commandContextActions !== undefined) {
|
||||
this._extensionCommandContextActions = bindings.commandContextActions;
|
||||
}
|
||||
@@ -2136,7 +2142,7 @@ export class AgentSession {
|
||||
}
|
||||
|
||||
private _applyExtensionBindings(runner: ExtensionRunner): void {
|
||||
runner.setUIContext(this._extensionUIContext);
|
||||
runner.setUIContext(this._extensionUIContext, this._extensionMode);
|
||||
runner.bindCommandContext(this._extensionCommandContextActions);
|
||||
|
||||
this._extensionErrorUnsubscriber?.();
|
||||
|
||||
Reference in New Issue
Block a user