/** * Tenancy awareness helpers. * * The backend derives the caller's team + hive scope SERVER-SIDE from the API * key (api_keys.team_id / default_hive_id + api_key_hive_access grants). The MCP * cannot assert tenancy and there is no per-request "team" override — one API * key = one tenant scope. * * Verification: at every server start the MCP calls `GET /v1/subscription` * (X-API-Key → `{"plan": "free" | "pro" | "team"}`) — the authoritative signal * for the key's real scope — via syncTenancyAtStartup() in scopeSync.ts, and * records the result here with setLivePlan(). The live plan always wins over * the team/plan metadata the `bhived` CLI recorded at sign-in, because a * valid-but-unprovisioned key silently degrades to PUBLIC-ONLY with NO error * and provisioning can change after sign-in. When the live check fails, the * stored metadata is the fallback and copy stays explicitly cautious. */ export type TenancyState = "team" | "personal" | "unknown"; export interface Tenancy { state: TenancyState; teamId?: string; teamName?: string; plan?: string; /** True when the state comes from a live GET /v1/subscription check. */ verified: boolean; } /** Record the live plan fetched from GET /v1/subscription (authoritative). */ export declare function setLivePlan(plan: "free" | "pro" | "team"): void; /** * Outcome of the most recent GET /v1/subscription attempt, so copy can tell * "older backend without the endpoint" apart from "rejected key" and * "network down" instead of blaming connectivity for everything. */ export type LiveCheckOutcome = { kind: "not_run"; } | { kind: "ok"; } | { kind: "http"; status: number; } | { kind: "invalid_response"; } | { kind: "unreachable"; }; export declare function setLiveCheckOutcome(outcome: LiveCheckOutcome): void; export declare function getLiveCheckOutcome(): LiveCheckOutcome; /** Human-readable reason the last live check yielded no plan; null after success. */ export declare function describeLiveCheckFailure(): string | null; /** * Provenance phrase for scope claims in agent-facing copy (tool descriptions, * server instructions). MUST track `verified` — claiming verification that * never happened recreates the silent-degrade trap this feature removes. */ export declare function verificationPhrase(): string; /** Resolve tenancy: live subscription check first, stored sign-in metadata as fallback. */ export declare function getTenancy(): Tenancy; /** * One-line scope banner for query/write output. * * `mode`: * - "read" → describes where results came from. * - "write" → describes where a write lands (team-private vs public). */ export declare function tenancyBanner(mode: "read" | "write"): string; //# sourceMappingURL=tenancy.d.ts.map