"use client";
import { create } from "@bufbuild/protobuf";
import { ListArtifactsByExecutionRequestSchema } from "@stigmer/protos/ai/stigmer/agentic/artifact/v1/io_pb";
import { useStigmer } from "../hooks";
import { useFetch } from "../internal/useFetch";
/**
 * Data hook that fetches artifacts produced by a workflow execution.
 *
 * Pass `null` for `executionId` to skip fetching.
 *
 * @example
 * ```tsx
 * const { artifacts, isLoading } = useWorkflowExecutionArtifacts(executionId);
 * ```
 */
export function useWorkflowExecutionArtifacts(executionId) {
    const stigmer = useStigmer();
    const fetchFn = executionId
        ? async () => {
            const resp = await stigmer.artifact.listByExecution(create(ListArtifactsByExecutionRequestSchema, {
                workflowExecutionId: executionId,
            }));
            return [...resp.entries];
        }
        : null;
    const { data: artifacts, isLoading, isRefetching, error, refetch } = useFetch(fetchFn, [executionId, stigmer], [], { cacheKey: executionId ? `workflow-execution-artifacts:${executionId}` : undefined });
    return { artifacts, isLoading, isRefetching, error, refetch };
}
//# sourceMappingURL=useWorkflowExecutionArtifacts.js.map