417
*/
418
export function mapItemStarted(
420
>
params: ItemStartedNotification,
421
>
): (SessionAction | ChatAction)[] {
422
>
// Coalesce a sandbox pre-flight with its approval-guarded re-run: if the
423
>
// immediately-preceding commandExecution in this turn ran the same command
424
>
// and completed with no output (deferred as a pending pre-flight), reuse its
425
>
// still-open tool call instead of opening a second box. The escalation's
426
>
// `requestApproval` / `item/completed` then drive that box to its final
427
>
// state, so nothing new is emitted here.
428
>
if (params.item.type === 'commandExecution') {
429
const pending = state.pendingPreflight;
430
if (pending && pending.turnId === params.turnId && pending.command === unwrapShellInvocation(params.item.command ?? '')) {