44
55import type { Executor } from '../agents/executor.js' ;
66import type { Scout } from '../agents/scout.js' ;
7- import type { Locale , PIPELINE_STRINGS } from '../core/prompts.js' ;
7+ import type { LLMClient } from '../core/llm.js' ;
8+ import { getBandPrompt , type Locale , type PIPELINE_STRINGS } from '../core/prompts.js' ;
89import type { AgentContext , TokenReport } from '../core/protocol.js' ;
910import { createMessage } from '../core/protocol.js' ;
1011import type { Router , RouterStats } from '../core/router.js' ;
@@ -22,6 +23,8 @@ export interface StandardDepthContext {
2223 getTokenReport : ( ) => TokenReport ;
2324 getRouterStats : ( ) => RouterStats ;
2425 emit : ( event : PipelineEvent ) => void ;
26+ llm ?: LLMClient ;
27+ onToken ?: ( token : string ) => void ;
2528}
2629
2730export async function runStandard ( ctx : StandardDepthContext ) : Promise < PipelineResult > {
@@ -44,15 +47,22 @@ export async function runStandard(ctx: StandardDepthContext): Promise<PipelineRe
4447 detail : ctx . skipScout ? 'Executing (no scout)...' : 'Executing with research context...' ,
4548 } ) ;
4649
47- const execMsg = createMessage ( 'planner' , 'executor' , ctx . userRequest , scoutContext ) ;
48- const execCtx : AgentContext = { visibleMessages : [ ] } ;
49- const execResponse = await ctx . executor . process ( execMsg , execCtx ) ;
50-
51- const report = execResponse . payload . trim ( ) || emptyOutputMessage ( ctx . locale ) ;
50+ let report : string ;
51+ if ( ctx . llm && ctx . onToken ) {
52+ const bandPrompt = getBandPrompt ( ctx . userRequest , ctx . locale ) ;
53+ const fullPrompt = scoutContext ? `${ scoutContext } \n\n${ ctx . userRequest } ` : ctx . userRequest ;
54+ const { content } = await ctx . llm . chatStream ( bandPrompt , fullPrompt , 'executor' , 'execute' , ctx . onToken ) ;
55+ report = content . trim ( ) || emptyOutputMessage ( ctx . locale ) ;
56+ } else {
57+ const execMsg = createMessage ( 'planner' , 'executor' , ctx . userRequest , scoutContext ) ;
58+ const execCtx : AgentContext = { visibleMessages : [ ] } ;
59+ const execResponse = await ctx . executor . process ( execMsg , execCtx ) ;
60+ report = execResponse . payload . trim ( ) || emptyOutputMessage ( ctx . locale ) ;
61+ }
5262 ctx . emit ( { type : 'complete' , phase : 'report' , detail : 'Done (standard)' } ) ;
5363
5464 return {
55- success : ! ! execResponse . payload . trim ( ) ,
65+ success : ! ! report . trim ( ) ,
5666 report,
5767 tokenReport : ctx . getTokenReport ( ) ,
5868 routerStats : ctx . getRouterStats ( ) ,
0 commit comments