/**
 * auto-runtime-state.js — Thin facade over the AutoSession singleton for
 * consumers that only need active/paused state and tool tracking, without
 * importing the full auto.js module.
 *
 * Purpose: break the forced dependency on auto.js (>1700 lines) for modules
 * that only need isAutoActive(), isAutoPaused(), markToolStart/End, or
 * recordToolInvocationError. All state reads delegate to the same singleton
 * that auto.js manages, so there is no separate instance.
 *
 * Consumer: forensics.js, rethink.js, ui/index.js, commands-handlers.js,
 * bootstrap/ask-gate.js, steerable-autonomous-extension.js.
 */
import { getAutoSession } from "./auto/session.js";
import {
	isDeterministicPolicyError,
	isQueuedUserMessageSkip,
	isToolInvocationError,
	markToolEnd as markTrackedToolEnd,
	markToolStart as markTrackedToolStart,
} from "./auto-tool-tracking.js";
export function getAutoRuntimeSnapshot() {
	const s = getAutoSession();
	return {
		active: s.active,
		paused: s.paused,
		currentUnit: s.currentUnit ? { ...s.currentUnit } : null,
		basePath: s.basePath,
	};
}
export function isAutoActive() {
	return getAutoSession().active;
}
export function isAutoPaused() {
	return getAutoSession().paused;
}
export function markToolStart(toolCallId, toolName) {
	markTrackedToolStart(toolCallId, getAutoSession().active, toolName);
}
export function markToolEnd(toolCallId) {
	markTrackedToolEnd(toolCallId);
}
export function recordToolInvocationError(toolName, errorMsg) {
	const s = getAutoSession();
	if (!s.active) return;
	if (
		isToolInvocationError(errorMsg) ||
		isQueuedUserMessageSkip(errorMsg) ||
		isDeterministicPolicyError(errorMsg)
	) {
		s.lastToolInvocationError = `${toolName}: ${errorMsg}`;
	}
}
