feat: enhances the capabilities of subagents by allowing them to use tools that require user

confirmation
This commit is contained in:
tanzhenxin
2025-09-11 15:16:52 +08:00
parent 88941daf93
commit d0735e8eb4
8 changed files with 383 additions and 297 deletions

View File

@@ -5,6 +5,10 @@
*/
import { EventEmitter } from 'events';
import {
ToolCallConfirmationDetails,
ToolConfirmationOutcome,
} from '../tools/tools.js';
export type SubAgentEvent =
| 'start'
@@ -13,6 +17,7 @@ export type SubAgentEvent =
| 'stream_text'
| 'tool_call'
| 'tool_result'
| 'tool_waiting_approval'
| 'finish'
| 'error';
@@ -23,6 +28,7 @@ export enum SubAgentEventType {
STREAM_TEXT = 'stream_text',
TOOL_CALL = 'tool_call',
TOOL_RESULT = 'tool_result',
TOOL_WAITING_APPROVAL = 'tool_waiting_approval',
FINISH = 'finish',
ERROR = 'error',
}
@@ -71,9 +77,25 @@ export interface SubAgentToolResultEvent {
timestamp: number;
}
export interface SubAgentApprovalRequestEvent {
subagentId: string;
round: number;
callId: string;
name: string;
description: string;
confirmationDetails: Omit<ToolCallConfirmationDetails, 'onConfirm'> & {
type: ToolCallConfirmationDetails['type'];
};
respond: (
outcome: ToolConfirmationOutcome,
payload?: Parameters<ToolCallConfirmationDetails['onConfirm']>[1],
) => Promise<void>;
timestamp: number;
}
export interface SubAgentFinishEvent {
subagentId: string;
terminate_reason: string;
terminateReason: string;
timestamp: number;
rounds?: number;
totalDurationMs?: number;