"use client";
import { create } from "@bufbuild/protobuf";
import { AgentExecutionSummaryTimeWindow, GetAgentExecutionSummaryRequestSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/io_pb";
import { useStigmer } from "../hooks.js";
import { useFetch } from "../internal/useFetch.js";
export { AgentExecutionSummaryTimeWindow };
/**
 * Data hook that fetches aggregated agent execution statistics for an
 * organization. Returns phase counts, active count, average duration,
 * and top failing agents.
 *
 * Cost is intentionally excluded from this response — the dashboard
 * sources cost from `useOrgUsageReport` (billing source of truth) to
 * prevent double-counting. See AD-DASH-005.
 *
 * @since Unified Platform Dashboard
 */
export function useAgentExecutionSummary(options) {
    const stigmer = useStigmer();
    const org = options.org ?? "";
    const timeWindow = options.timeWindow ??
        AgentExecutionSummaryTimeWindow.LAST_7D;
    const refetchInterval = options.refetchInterval ?? 0;
    const fetchFn = org
        ? async () => {
            return await stigmer.agentExecution.getExecutionSummary(create(GetAgentExecutionSummaryRequestSchema, { org, timeWindow }));
        }
        : null;
    const { data, isLoading, isRefetching, error, refetch } = useFetch(fetchFn, [stigmer, org, timeWindow], null, { refetchInterval: refetchInterval || false });
    return { summary: data, isLoading, isRefetching, error, refetch };
}
//# sourceMappingURL=useAgentExecutionSummary.js.map