"use client";
import { useCallback } from "react";
import { useStigmer } from "../hooks";
/**
 * Behavior hook that resolves the current auth credential for passing
 * to a runner sidecar process.
 *
 * This is the SDK-level abstraction for starting runners from within
 * a desktop or native application — where the app already holds the
 * credential and needs to hand it to a CLI child process. It avoids
 * the `createLaunchToken` / `exchangeLaunchToken` round-trip, which
 * is only needed for cross-process browser-to-desktop handshakes
 * (see {@link useLaunchLocalRunner} for that scenario).
 *
 * The hook reads from `useStigmer()` and calls
 * `client.getAuthCredential()`, so it works identically regardless
 * of auth mode (Auth0 JWT, PlatformClient JWT, API key).
 *
 * @example
 * ```tsx
 * function StartRunnerButton({ org }: { org: string }) {
 *   const { getCredential } = useRunnerCredential();
 *
 *   const handleStart = async () => {
 *     const cred = await getCredential(org);
 *     // Pass cred.token, cred.endpoint, cred.org to your sidecar
 *     await nativeBridge.startRunner({
 *       token: cred.token,
 *       endpoint: cred.endpoint,
 *       org: cred.org,
 *     });
 *   };
 *
 *   return <button onClick={handleStart}>Start Runner</button>;
 * }
 * ```
 */
export function useRunnerCredential() {
    const stigmer = useStigmer();
    const getCredential = useCallback(async (org) => {
        const token = await stigmer.getAuthCredential();
        return {
            token,
            endpoint: stigmer.baseUrl,
            org,
        };
    }, [stigmer]);
    return { getCredential };
}
//# sourceMappingURL=useRunnerCredential.js.map