Files
zerobyte/app/server/modules/lifecycle/bootstrap.ts
Nico 28ba8657f9 feat(runtime): start and ship the local agent (#767)
* feat(runtime): start and ship the local agent

* refactor: gate local agent behind feature flag

* chore: skip agent manager if flag is false

* fix: hot reload agents

* test: fix config tests
2026-04-10 00:00:30 +02:00

38 lines
851 B
TypeScript

import { runDbMigrations } from "../../db/db";
import { spawnLocalAgent, startAgentRuntime, stopAgentRuntime } from "../agents/agents-manager";
import { runMigrations } from "./migrations";
import { startup } from "./startup";
let bootstrapPromise: Promise<void> | undefined;
const runBootstrap = async () => {
await runDbMigrations();
await runMigrations();
if (process.env.ENABLE_LOCAL_AGENT === "true") {
await startAgentRuntime();
await spawnLocalAgent();
}
await startup();
};
export const bootstrapApplication = async () => {
if (!bootstrapPromise) {
bootstrapPromise = runBootstrap();
}
try {
await bootstrapPromise;
} catch (err) {
bootstrapPromise = undefined;
throw err;
}
};
export const stopApplicationRuntime = async () => {
try {
await stopAgentRuntime();
} finally {
bootstrapPromise = undefined;
}
};