feat(FN-1053): add AI prompt executor for cron workflow steps

- Define AiPromptExecutor type and update CronRunner constructor to accept injected executor
- Implement executeAiPromptStep with real agent session execution in worktrees
- Create createAiPromptStepExecutor factory and wire up in dashboard CLI
- Add comprehensive tests for AI prompt step execution (mock agent, errors, output capture)
- Fix mock typing for dashboard test build compatibility
This commit is contained in:
gsxdsm
2026-04-07 11:20:48 -07:00
parent 1c10f2f27b
commit 7af1317f34
5 changed files with 388 additions and 23 deletions

View File

@@ -122,6 +122,7 @@ vi.mock("@fusion/engine", async (importOriginal) => {
})),
scanIdleWorktrees: vi.fn().mockResolvedValue([]),
cleanupOrphanedWorktrees: vi.fn().mockResolvedValue(0),
createAiPromptExecutor: vi.fn().mockResolvedValue(vi.fn().mockResolvedValue("mock AI response")),
};
});

View File

@@ -4,7 +4,7 @@ import { createInterface } from "node:readline";
import { TaskStore, AutomationStore, CentralCore, AgentStore, getTaskMergeBlocker } from "@fusion/core";
import type { Settings, TaskDetail, PrInfo } from "@fusion/core";
import { createServer, GitHubClient } from "@fusion/dashboard";
import { TriageProcessor, TaskExecutor, Scheduler, AgentSemaphore, WorktreePool, aiMergeTask, UsageLimitPauser, PRIORITY_MERGE, scanIdleWorktrees, cleanupOrphanedWorktrees, NtfyNotifier, PrMonitor, PrCommentHandler, CronRunner, StuckTaskDetector, SelfHealingManager, MissionAutopilot } from "@fusion/engine";
import { TriageProcessor, TaskExecutor, Scheduler, AgentSemaphore, WorktreePool, aiMergeTask, UsageLimitPauser, PRIORITY_MERGE, scanIdleWorktrees, cleanupOrphanedWorktrees, NtfyNotifier, PrMonitor, PrCommentHandler, CronRunner, StuckTaskDetector, SelfHealingManager, MissionAutopilot, createAiPromptExecutor } from "@fusion/engine";
import { AuthStorage, DefaultPackageManager, ModelRegistry, SettingsManager, discoverAndLoadExtensions, getAgentDir, createExtensionRuntime } from "@mariozechner/pi-coding-agent";
/**
@@ -653,7 +653,8 @@ export async function runDashboard(port: number, opts: { paused?: boolean; dev?:
missionAutopilot.setScheduler(scheduler);
// ── CronRunner: scheduled task execution ──────────────────────────
const cronRunner = new CronRunner(store, automationStore);
const aiPromptExecutor = await createAiPromptExecutor(cwd);
const cronRunner = new CronRunner(store, automationStore, { aiPromptExecutor });
cronRunner.start();
triage.start();