feat(FN-4015): classify and recover from stale module-resolution incidents

Merges FN-4015 to add stale module-resolution incident detection and self-healing in the engine (`transient-error-detector.ts`, `self-healing.ts`) with mobile regression coverage for the shared `AgentErrorDetailsModal` layout.

Fusion-Task-Id: FN-4015
This commit is contained in:
Fusion
2026-05-11 11:59:07 -07:00
committed by gsxdsm
parent a8ef54c7f9
commit 42087ddfeb
8 changed files with 301 additions and 15 deletions

View File

@@ -170,6 +170,27 @@ export function classifyError(errorMessage: string): "transient" | "usage-limit"
return "permanent";
}
const STALE_WORKTREE_MODULE_RESOLUTION_PATTERN = /Cannot find module\s+['"][^'"]*node_modules[^'"]*['"][\s\S]*imported from\s+/i;
const STALE_WORKTREE_MODULE_PATH_PATTERN = /Cannot find module\s+['"]([^'"]*node_modules[^'"]*)['"]/i;
export function isStaleWorktreeModuleResolutionError(errorMessage: string): boolean {
if (!errorMessage || typeof errorMessage !== "string") {
return false;
}
return STALE_WORKTREE_MODULE_RESOLUTION_PATTERN.test(errorMessage);
}
export function extractMissingModulePath(errorMessage: string): string | null {
if (!errorMessage || typeof errorMessage !== "string") {
return null;
}
const match = errorMessage.match(STALE_WORKTREE_MODULE_PATH_PATTERN);
if (!match?.[1]) {
return null;
}
return match[1];
}
const OPERATOR_ACTIONABLE_AGENT_ERROR_PATTERNS: RegExp[] = [
/invalid api key/i,
/authentication failed/i,