import { DEFAULT_HEARTBEAT_FILENAME } from "../context/workspace.js";
import { isProfileBootstrapPending, loadProfileBootstrapFiles } from "./load-bootstrap-files.js";
import { clearAllBootstrapSnapshots, clearBootstrapSnapshot, getOrLoadBootstrapFiles } from "./bootstrap-cache.js";
import { buildBootstrapContextFiles, resolveBootstrapMaxChars, resolveBootstrapTotalMaxChars } from "./bootstrap-context.js";
import { filterBootstrapFilesForSession } from "./filter-bootstrap-files.js";
//#region src/agent/bootstrap/bootstrap-files.ts
function filterHeartbeatBootstrapFile(files, exclude) {
	if (!exclude) return files;
	return files.filter((file) => file.name !== DEFAULT_HEARTBEAT_FILENAME);
}
function resolveBootstrapFilesSync(params) {
	return filterHeartbeatBootstrapFile(filterBootstrapFilesForSession(loadProfileBootstrapFiles(params.profileDir), params.sessionKey), params.excludeHeartbeat ?? false);
}
async function resolveBootstrapFilesForRun(params) {
	const sessionKey = params.sessionKey;
	return filterHeartbeatBootstrapFile(filterBootstrapFilesForSession(sessionKey ? await getOrLoadBootstrapFiles({
		profileDir: params.profileDir,
		sessionKey
	}) : loadProfileBootstrapFiles(params.profileDir), sessionKey), params.excludeHeartbeat ?? false);
}
function resolveBootstrapContextSync(params) {
	const bootstrapFiles = resolveBootstrapFilesSync(params);
	return {
		bootstrapFiles,
		contextFiles: buildBootstrapContextFiles(bootstrapFiles, {
			maxChars: resolveBootstrapMaxChars(params.config),
			totalMaxChars: resolveBootstrapTotalMaxChars(params.config)
		})
	};
}
async function resolveBootstrapContextForRun(params) {
	const bootstrapFiles = await resolveBootstrapFilesForRun(params);
	return {
		bootstrapFiles,
		contextFiles: buildBootstrapContextFiles(bootstrapFiles, {
			maxChars: resolveBootstrapMaxChars(params.config),
			totalMaxChars: resolveBootstrapTotalMaxChars(params.config),
			warn: params.warn
		})
	};
}
//#endregion
export { clearAllBootstrapSnapshots, clearBootstrapSnapshot, isProfileBootstrapPending, resolveBootstrapContextForRun, resolveBootstrapContextSync, resolveBootstrapFilesForRun, resolveBootstrapFilesSync };

//# sourceMappingURL=bootstrap-files.js.map