Files
openclaw/src/agents/bootstrap-mode.ts
Ben Badejo 180a970ac0 fix(heartbeat): scope commitment fan-out prompts (#98169)
* fix(heartbeat): scope commitment fan-out prompts

* fix(heartbeat): isolate commitment fan-out runs

* fix(heartbeat): isolate commitment fan-out runs

---------

Co-authored-by: Benjamin Badejo <ben@benbadejo.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-06-30 20:25:28 -07:00

34 lines
1.2 KiB
TypeScript

// Bootstrap mode resolver for deciding whether a run gets full, limited, or no
// workspace bootstrap files.
export type BootstrapMode = "full" | "limited" | "none";
export type BootstrapContextRunKind = "default" | "heartbeat" | "cron" | "commitment-only";
export function isHeartbeatLifecycleRunKind(runKind: BootstrapContextRunKind | undefined): boolean {
return runKind === "heartbeat" || runKind === "commitment-only";
}
/** Resolve the bootstrap mode for one agent run. */
export function resolveBootstrapMode(params: {
bootstrapPending: boolean;
runKind?: BootstrapContextRunKind;
isInteractiveUserFacing: boolean;
isPrimaryRun: boolean;
isCanonicalWorkspace: boolean;
hasBootstrapFileAccess: boolean;
}): BootstrapMode {
if (!params.bootstrapPending) {
return "none";
}
if (isHeartbeatLifecycleRunKind(params.runKind) || params.runKind === "cron") {
// Background maintenance turns should not consume or mutate bootstrap state.
return "none";
}
if (!params.isPrimaryRun || !params.isInteractiveUserFacing) {
return "none";
}
if (!params.hasBootstrapFileAccess) {
return "limited";
}
return params.isCanonicalWorkspace ? "full" : "limited";
}