Files
fusion/.changeset/cli-agent-executor-seam.md
gsxdsm c1c99a9de0 feat(engine): wire cli-agent executor seam and task session lifecycle (U7)
Add `cli-agent` as a task-execute executor kind. A workflow node with
`config.executor === "cli-agent"` drives an engine-owned CLI coding agent
through the execute step via the new cli-agent/task-session.ts orchestration:
spawn in the worktree, issue the hook token + write hook scripts, inject the
prompt after readiness, subscribe to the state machine, and resolve on a
positive completion signal (R20 gating). Config is snapshotted at launch; the
PTY is reaped (completed) at the in-review handoff.

Executor seam: runGraphCustomNode gains a cli-agent branch delegating to
runCliAgentNode; the hard-cancel/abort path (awaitAbortInFlightTaskWork +
abortAllInFlight) claims and SIGKILLs the CLI session as a first-class surface,
marking it killed (never resume-eligible). Re-entry kills any prior live
session and launches fresh; follow-up resumes the recorded native session id
when supported. A PTY-pool ceiling surfaces as a typed task value, not a stall.

Node-config typing extended minimally (WorkflowNodeExecutorKind /
WorkflowNodeExecutorConfig in @fusion/core).

Tests: cli-agent/__tests__/task-session.test.ts (12) and
__tests__/cli-agent-executor.test.ts (9) cover AE1/AE5, hard cancel, re-entry,
follow-up, config snapshot, ceiling, and the generic-tier confirm-advance path,
using scripted adapters + a mock PTY seam. Engine typecheck clean; full
src/cli-agent suite + new tests green (144 passing).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 00:01:12 -07:00

1.5 KiB

@runfusion/fusion
@runfusion/fusion
minor

Wire the CLI Agent Executor as a selectable executor kind for the task execute path (U7). A workflow node with config.executor === "cli-agent" (plus cliAdapterId and optional cliAutonomy/cliNotify) now drives an engine-owned CLI coding agent (Claude Code / Codex / Droid / Pi / generic) through the execute step inside the task worktree.

The new cli-agent/task-session.ts orchestrates the task↔session lifecycle: spawn in the worktree, mint the per-session hook token and write the hook scripts, inject the task prompt after readiness, subscribe to the authoritative state machine, and resolve on a positive completion signal (origin R20 gating — a native done advances the pipeline; the generic tier never auto-advances on idle and exposes a confirmAdvance() affordance instead). The resolved executor config is snapshotted at launch, so a mid-run node-config edit applies to the next run only. The PTY is reaped (recorded completed) at the execute→in-review handoff.

Lifecycle semantics honor the existing contracts: a hard cancel (moveTask(in-progress→todo) / column-exit abort) SIGKILLs the CLI session via the same dispose/abort path API sessions use and marks it killed (never resume-eligible); a re-plan/RETHINK re-entry kills any prior live session and launches fresh; a follow-up to a done task resumes the recorded native session id when the adapter supports resume, else launches fresh. A PTY-pool ceiling (CliConcurrencyLimitError) surfaces as a clear queued/rejected task state rather than a silent stall.