mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-29 14:34:55 -07:00
feat(scheduler): add types needed for event driven scheduler (#16641)
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
*/
|
||||
|
||||
import { type FunctionCall } from '@google/genai';
|
||||
import type {
|
||||
ToolConfirmationOutcome,
|
||||
ToolConfirmationPayload,
|
||||
} from '../tools/tools.js';
|
||||
import type { ToolCall } from '../scheduler/types.js';
|
||||
|
||||
export enum MessageBusType {
|
||||
TOOL_CONFIRMATION_REQUEST = 'tool-confirmation-request',
|
||||
@@ -16,6 +21,12 @@ export enum MessageBusType {
|
||||
HOOK_EXECUTION_REQUEST = 'hook-execution-request',
|
||||
HOOK_EXECUTION_RESPONSE = 'hook-execution-response',
|
||||
HOOK_POLICY_DECISION = 'hook-policy-decision',
|
||||
TOOL_CALLS_UPDATE = 'tool-calls-update',
|
||||
}
|
||||
|
||||
export interface ToolCallsUpdateMessage {
|
||||
type: MessageBusType.TOOL_CALLS_UPDATE;
|
||||
toolCalls: ToolCall[];
|
||||
}
|
||||
|
||||
export interface ToolConfirmationRequest {
|
||||
@@ -23,12 +34,26 @@ export interface ToolConfirmationRequest {
|
||||
toolCall: FunctionCall;
|
||||
correlationId: string;
|
||||
serverName?: string;
|
||||
/**
|
||||
* Optional rich details for the confirmation UI (diffs, counts, etc.)
|
||||
*/
|
||||
details?: SerializableConfirmationDetails;
|
||||
}
|
||||
|
||||
export interface ToolConfirmationResponse {
|
||||
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE;
|
||||
correlationId: string;
|
||||
confirmed: boolean;
|
||||
/**
|
||||
* The specific outcome selected by the user.
|
||||
*
|
||||
* TODO: Make required after migration.
|
||||
*/
|
||||
outcome?: ToolConfirmationOutcome;
|
||||
/**
|
||||
* Optional payload (e.g., modified content for 'modify_with_editor').
|
||||
*/
|
||||
payload?: ToolConfirmationPayload;
|
||||
/**
|
||||
* When true, indicates that policy decision was ASK_USER and the tool should
|
||||
* show its legacy confirmation UI instead of auto-proceeding.
|
||||
@@ -36,6 +61,35 @@ export interface ToolConfirmationResponse {
|
||||
requiresUserConfirmation?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data-only versions of ToolCallConfirmationDetails for bus transmission.
|
||||
*/
|
||||
export type SerializableConfirmationDetails =
|
||||
| { type: 'info'; title: string; prompt: string; urls?: string[] }
|
||||
| {
|
||||
type: 'edit';
|
||||
title: string;
|
||||
fileName: string;
|
||||
filePath: string;
|
||||
fileDiff: string;
|
||||
originalContent: string | null;
|
||||
newContent: string;
|
||||
}
|
||||
| {
|
||||
type: 'exec';
|
||||
title: string;
|
||||
command: string;
|
||||
rootCommand: string;
|
||||
rootCommands: string[];
|
||||
}
|
||||
| {
|
||||
type: 'mcp';
|
||||
title: string;
|
||||
serverName: string;
|
||||
toolName: string;
|
||||
toolDisplayName: string;
|
||||
};
|
||||
|
||||
export interface UpdatePolicy {
|
||||
type: MessageBusType.UPDATE_POLICY;
|
||||
toolName: string;
|
||||
@@ -94,4 +148,5 @@ export type Message =
|
||||
| UpdatePolicy
|
||||
| HookExecutionRequest
|
||||
| HookExecutionResponse
|
||||
| HookPolicyDecision;
|
||||
| HookPolicyDecision
|
||||
| ToolCallsUpdateMessage;
|
||||
|
||||
Reference in New Issue
Block a user