/**
 * ShareBackend — the token-source seam for `agents artifacts share`.
 *
 * Two legitimate principals, picked once at publish time:
 *   - **managed**: the caller is signed in to Phoenix (`readSession()`), no
 *     explicit BYO override. Token is the Phoenix access_token; endpoint is
 *     the already-live `share.getrush.ai`. Zero Cloudflare setup.
 *   - **byo**: the existing static WRITE_TOKEN path (`readShareConfig()` +
 *     `readWriteToken()`). Unchanged for power users / custom domains / fleet
 *     injection of `SHARE_WRITE_TOKEN`.
 *
 * Dispatch is not a fallback: signed-in AND no BYO override → managed;
 * otherwise BYO. Fail loud when neither principal can authenticate.
 *
 * Explicit BYO override (any one is enough):
 *   - `opts.byo === true`
 *   - `opts.writeToken` (a caller-supplied static token, including tests)
 *   - `AGENTS_SHARE_BACKEND=byo`
 */
import { type PhoenixSession } from '../identity/client.js';
import { type ShareConfig } from './config.js';
export type ShareBackendKind = 'managed' | 'byo';
export interface ShareBackend {
    kind: ShareBackendKind;
    /** Public base URL of the share Worker, no trailing slash. */
    baseUrl: string;
    /** Bearer sent as `Authorization`. Phoenix access_token or WRITE_TOKEN. */
    token: string;
    /** URL namespace prefix (`<namespace>/<slug>`). Phoenix handle (email local-part) or GitHub username. */
    namespace: string;
}
export interface ResolveShareBackendOpts {
    /** Force the BYO Cloudflare path even when signed in. */
    byo?: boolean;
    /** Override the namespace (BYO: GitHub username; ignored on managed — the
     * worker 403s a Phoenix PUT whose first segment is not the verified handle). */
    githubUser?: string;
    /** DI seam — a static write token selects BYO. */
    writeToken?: string;
    /** DI seam — persisted BYO endpoint config. */
    config?: ShareConfig;
    /** DI seam — override `readSession()`. `null` means signed out. */
    session?: PhoenixSession | null;
    /**
     * When false, BYO may resolve without a WRITE_TOKEN. Public GET routes
     * (list / revisions / status) don't need one; publish and delete do.
     * Default true.
     */
    requireToken?: boolean;
}
/** Env var that forces the BYO path. Value must be exactly `byo`. */
export declare const SHARE_BACKEND_ENV = "AGENTS_SHARE_BACKEND";
/** URL-safe namespace: lowercase `[a-z0-9-]+`. Matches the Worker's sanitize.
 *
 * This is URL-safety, not collision-resistance: two values that differ only
 * in case or punctuation share a prefix. */
export declare function sanitizeShareNamespace(s: string): string;
/**
 * Public managed-share handle from a verified email.
 *
 * `muqsitnawaz@gmail.com` → `muqsitnawaz`. Plus-tags are dropped
 * (`muqsitnawaz+dev@gmail.com` → `muqsitnawaz`) so the URL stays the
 * account's default name. Empty / missing email → `''` (caller falls
 * back to userId). Must match the Worker `handleFromEmail`.
 */
export declare function handleFromEmail(email: string | undefined): string;
/** Managed URL namespace: email handle, else sanitized userId (never empty if either is set). */
export declare function managedShareHandle(session: Pick<PhoenixSession, 'email' | 'userId'>): string;
export declare function managedShareBaseUrl(): string;
/**
 * True when this config is the platform managed endpoint (`share.getrush.ai`, or a
 * legacy alias — `share.agents-cli.sh` / `artifacts.prix.dev` — still bound to the
 * same Worker). The
 * deploy path uses this — not "the caller is signed in" — to decide whether to
 * bind `PHOENIX_ID_BASE` on the Worker.
 */
export declare function isManagedShareEndpoint(cfg: {
    baseUrl?: string;
    domain?: string;
}): boolean;
/**
 * Phoenix ID URL to bind on a managed Worker deploy. `undefined` for a
 * pure-BYO Worker (WRITE_TOKEN only). Fail loud if this is a managed deploy
 * but the base is empty — never skip-set a blank secret.
 */
export declare function phoenixIdBaseForDeploy(opts?: {
    managed?: boolean;
}, cfg?: {
    baseUrl?: string;
    domain?: string;
}): string | undefined;
/**
 * Pick the principal via the shared selection policy. Signed-in AND no explicit
 * BYO override → managed; otherwise BYO.
 */
export declare function shouldUseManaged(opts?: ResolveShareBackendOpts): boolean;
export declare function resolveShareBackend(opts?: ResolveShareBackendOpts): ShareBackend;
