feat:add ask_question tool as builtin-tools (#3107)

This commit is contained in:
Aries-ckt
2026-07-12 18:51:38 +08:00
committed by GitHub
parent 209588ddd5
commit 2d1663cf5c
30 changed files with 2553 additions and 1303 deletions

View File

@@ -66,12 +66,47 @@ export interface SSEContextStatusEvent {
compact_layer?: string | null;
}
// ── Human-in-the-loop: question events ──────────────────────────────────────
export interface QuestionOption {
label: string;
description: string;
}
export interface QuestionInfo {
question: string;
header: string;
options: QuestionOption[];
multiple?: boolean;
custom?: boolean;
}
export interface SSEQuestionAskedEvent {
type: 'question.asked';
request_id: string;
conv_id: string;
questions: QuestionInfo[];
}
export interface SSEQuestionRepliedEvent {
type: 'question.replied';
request_id: string;
}
export interface SSEQuestionRejectedEvent {
type: 'question.rejected';
request_id: string;
}
export type SSEEvent =
| SSEStepStartEvent
| SSEStepChunkEvent
| SSEStepMetaEvent
| SSEStepDoneEvent
| SSEContextStatusEvent
| SSEQuestionAskedEvent
| SSEQuestionRepliedEvent
| SSEQuestionRejectedEvent
| SSEFinalEvent
| SSEDoneEvent;
@@ -108,6 +143,7 @@ export class ReActSSEState {
private startTime: number;
private endTime?: number;
private _contextStatus: ContextStatus | null = null;
private _pendingQuestion: SSEQuestionAskedEvent | null = null;
constructor() {
this.startTime = Date.now();
@@ -133,6 +169,13 @@ export class ReActSSEState {
case 'context.status':
this.handleContextStatus(event);
break;
case 'question.asked':
this._pendingQuestion = event;
break;
case 'question.replied':
case 'question.rejected':
this._pendingQuestion = null;
break;
case 'final':
this.handleFinal(event);
break;
@@ -142,6 +185,13 @@ export class ReActSSEState {
}
}
/**
* Get the current pending question (null if none)
*/
getPendingQuestion(): SSEQuestionAskedEvent | null {
return this._pendingQuestion;
}
private handleStepStart(event: SSEStepStartEvent): void {
const step: StepState = {
id: event.id,