fix(engine): make heartbeat helper imports static to fail fast on partial dist

Convert the dynamic await import("./agent-session-helpers.js") and
await import("./session-skill-context.js") calls inside the heartbeat
executor to static top-level imports, matching the rationale of
38933c770 (which already made the sibling pi.js import static).
This surfaces ERR_MODULE_NOT_FOUND at engine load time rather than
mid-heartbeat when a worktree is on a branch missing the helpers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-06 06:49:30 -07:00
parent 9be551b3a2
commit a143bcc4f5
2 changed files with 11 additions and 3 deletions

View File

@@ -0,0 +1,9 @@
---
"@runfusion/fusion": patch
---
Convert the heartbeat executor's dynamic `import("./agent-session-helpers.js")`
and `import("./session-skill-context.js")` calls to static imports. This makes
missing or partial engine dist surface at module load time (matching the
existing static `pi.js` import) instead of failing mid-heartbeat with a
confusing `ERR_MODULE_NOT_FOUND`.

View File

@@ -33,6 +33,8 @@ import {
import { heartbeatLog, formatError } from "./logger.js"; import { heartbeatLog, formatError } from "./logger.js";
import { createRunAuditor, type EngineRunContext } from "./run-audit.js"; import { createRunAuditor, type EngineRunContext } from "./run-audit.js";
import { promptWithFallback } from "./pi.js"; import { promptWithFallback } from "./pi.js";
import { createResolvedAgentSession, extractRuntimeHint, extractRuntimeModel } from "./agent-session-helpers.js";
import { buildSessionSkillContextSync } from "./session-skill-context.js";
import type { AgentReflectionService } from "./agent-reflection.js"; import type { AgentReflectionService } from "./agent-reflection.js";
interface SelfImproveServiceLike { interface SelfImproveServiceLike {
@@ -1598,9 +1600,6 @@ export class HeartbeatMonitor {
}, },
}; };
const { createResolvedAgentSession, extractRuntimeHint, extractRuntimeModel } = await import("./agent-session-helpers.js");
const { buildSessionSkillContextSync } = await import("./session-skill-context.js");
// Build tools with task creation tracking and run context for mutation correlation // Build tools with task creation tracking and run context for mutation correlation
// For no-task runs, exclude fn_task_log and document tools (they require a taskId) // For no-task runs, exclude fn_task_log and document tools (they require a taskId)
let heartbeatTools: ToolDefinition[]; let heartbeatTools: ToolDefinition[];