Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: load agentApiAuth lazily in the autonomous-job script handlers (#12566)

[._.]/ Adam Eivybcc16525d675
diff --git a/server/services/autonomousJobs/scriptHandlers.js b/server/services/autonomousJobs/scriptHandlers.js
index bce07c3632..0ba7cedfb2 100644
--- a/server/services/autonomousJobs/scriptHandlers.js
+++ b/server/services/autonomousJobs/scriptHandlers.js
@@ -17,7 +17,6 @@ import { cleanupOrphanedWorktrees, reapMergedWorktrees } from '../worktreeManage
import { getActiveAgentIds } from '../agentState.js'
import { sweepStaleDoneSentinels } from '../agentSentinelSweep.js'
import { runSelfDiagnostics } from './selfDiagnostics.js'
-import { resolveAgentApiEnv } from '../agentApiAuth.js'
import { runBrainParitySweep } from './brainParitySweep.js'
// Loaded lazily to keep the built-in handler registry free of an import cycle:
@@ -36,6 +35,8 @@ async function runMoltworldExploration() {
const scriptPath = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'scripts', 'moltworld-explore.mjs')
const durationMinutes = process.env.MOLTWORLD_DURATION_MINUTES || '30'
+ // Lazy: agentApiAuth pulls in the session/auth stack, which this registry must not load at import time.
+ const { resolveAgentApiEnv } = await import('../agentApiAuth.js');
const apiEnv = await resolveAgentApiEnv();
return new Promise((resolve, reject) => {