TeamLeaderRunner を4モジュールに分割(execution, aggregation, common, streaming)し、 パート完了時にキュー残数が refill_threshold 以下になると追加タスクを動的に生成する worker pool 型の実行モデルを実装。ParallelLogger に LineTimeSliceBuffer を追加し ストリーミング出力を改善。deep-research ピースに team_leader 設定を追加。
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { getLabel } from '../../../shared/i18n/index.js';
|
|
import type { PieceEngineOptions } from '../types.js';
|
|
import type { ParallelLoggerOptions } from './parallel-logger.js';
|
|
|
|
export function buildTeamLeaderParallelLoggerOptions(
|
|
engineOptions: PieceEngineOptions,
|
|
movementName: string,
|
|
movementIteration: number,
|
|
subMovementNames: string[],
|
|
iteration: number,
|
|
maxMovements: number,
|
|
): ParallelLoggerOptions {
|
|
const options: ParallelLoggerOptions = {
|
|
subMovementNames,
|
|
parentOnStream: engineOptions.onStream,
|
|
progressInfo: { iteration, maxMovements },
|
|
};
|
|
|
|
if (engineOptions.taskPrefix != null && engineOptions.taskColorIndex != null) {
|
|
return {
|
|
...options,
|
|
taskLabel: engineOptions.taskPrefix,
|
|
taskColorIndex: engineOptions.taskColorIndex,
|
|
parentMovementName: movementName,
|
|
movementIteration,
|
|
};
|
|
}
|
|
|
|
return options;
|
|
}
|
|
|
|
export function emitTeamLeaderProgressHint(
|
|
engineOptions: PieceEngineOptions,
|
|
kind: 'decompose' | 'feedback',
|
|
): void {
|
|
const onStream = engineOptions.onStream;
|
|
if (!onStream) {
|
|
return;
|
|
}
|
|
|
|
const key = kind === 'decompose'
|
|
? 'piece.teamLeader.decomposeWait'
|
|
: 'piece.teamLeader.feedbackWait';
|
|
const text = `${getLabel(key, engineOptions.language)}\n`;
|
|
|
|
onStream({ type: 'text', data: { text } });
|
|
}
|