function requireAdmin(ctx) {
    const address = ctx.user?.address?.toLowerCase();
    if (!address || !(ctx.isAdmin?.(address) ?? false)) {
        throw new Error("FORBIDDEN");
    }
}
export function createResolvers(deps) {
    return {
        Query: {
            VetraHousekeeping: () => ({}),
        },
        VetraHousekeepingQueries: {
            studioPowerState: (_p, args) => deps.powerState(args.host),
        },
        Mutation: {
            VetraHousekeeping: () => ({}),
        },
        VetraHousekeepingMutations: {
            // Manual "sleep now" — admin only.
            sleepStudio: (_p, args, ctx) => {
                requireAdmin(ctx);
                return deps.sleep(args.host);
            },
            // Open + idempotent: waking is inherently triggered by "someone wants this
            // studio" (the activator calls this for any visitor to a sleeping host),
            // and it only ever wakes a STOPPED env — so it needs no admin token, which
            // is what lets the long-running activator call it without an expiring
            // credential. Worst case is a wasted wake that re-sleeps within the window.
            wakeStudio: (_p, args) => deps.wake(args.host),
        },
    };
}
