1+ import type { HostEnvironment } from '@agent-device/kernel/source-value' ;
12import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog' ;
23import {
34 STRUCTURED_BATCH_COMMAND_NAMES ,
@@ -27,23 +28,32 @@ type PrepareDaemonCommandRequest = (
2728 command : string ,
2829 input : CommandInput ,
2930 stepNumber : number ,
31+ host : HostEnvironment ,
32+ ) => Promise < DaemonCommandRequest > ;
33+
34+ type PrepareBatchStep = (
35+ command : string ,
36+ input : CommandInput ,
37+ stepNumber : number ,
3038) => Promise < DaemonCommandRequest > ;
3139
3240export function createBatchDaemonWriter (
3341 prepareDaemonCommandRequest : PrepareDaemonCommandRequest ,
3442) : AsyncDaemonWriter {
35- return async ( input ) =>
43+ return async ( input , host ) =>
3644 request ( PUBLIC_COMMANDS . batch , [ ] , {
3745 ...input ,
38- batchSteps : await readBatchDaemonSteps ( input . steps , prepareDaemonCommandRequest ) ,
46+ batchSteps : await readBatchDaemonSteps ( input . steps , ( command , input , stepNumber ) =>
47+ prepareDaemonCommandRequest ( command , input , stepNumber , host ) ,
48+ ) ,
3949 batchOnError : input . onError ,
4050 batchMaxSteps : input . maxSteps ,
4151 } ) ;
4252}
4353
4454async function readBatchDaemonSteps (
4555 steps : unknown ,
46- prepareDaemonCommandRequest : PrepareDaemonCommandRequest ,
56+ prepareDaemonCommandRequest : PrepareBatchStep ,
4757) : Promise < DaemonBatchStep [ ] > {
4858 if ( ! Array . isArray ( steps ) || steps . length === 0 ) {
4959 throw new AppError ( 'INVALID_ARGS' , 'batch requires a non-empty steps array.' ) ;
@@ -60,7 +70,7 @@ async function readBatchDaemonSteps(
6070async function readBatchDaemonStep (
6171 step : unknown ,
6272 stepNumber : number ,
63- prepareDaemonCommandRequest : PrepareDaemonCommandRequest ,
73+ prepareDaemonCommandRequest : PrepareBatchStep ,
6474) : Promise < DaemonBatchStep > {
6575 const record = readBatchStepRecord ( step , stepNumber ) ;
6676 const command = readBatchStepCommand ( record , stepNumber ) ;
0 commit comments