import {
  CONTROL_PLANE_PROFILE,
  INCIDENT_PACKET_PROFILE,
  MCP_MEDIATED_VALUE,
  MCP_SCHEMA_COMMIT,
  MCP_SCHEMA_SHA256,
  MCP_SOURCE_PIN,
  MCP_STANDARDS_GATE,
  MCP_WIRE_PROTOCOL_REVISION,
  KEY_ROTATION_RETIREMENT_BLOCKER,
  PRODUCTION_STATUS,
} from "./constants";
export const PROFILE = INCIDENT_PACKET_PROFILE;
export const SERVICE_PROFILE = CONTROL_PLANE_PROFILE;
export {
  MCP_MEDIATED_VALUE,
  MCP_SCHEMA_COMMIT,
  MCP_SCHEMA_SHA256,
  MCP_SOURCE_PIN,
  MCP_STANDARDS_GATE,
  MCP_WIRE_PROTOCOL_REVISION,
  PRODUCTION_STATUS,
};
export const MATURITY = "experimental" as const;
export const DISTRIBUTION = "SOURCE_ONLY" as const;
export const DEPLOYMENT_GATE = "PASSED" as const;
export const RETIREMENT_EXPORT_GATE =
  "BLOCKED_OPERATOR_EXPORT_NOT_IMPLEMENTED" as const;
export const KEY_ROTATION_RETIREMENT_GATE =
  KEY_ROTATION_RETIREMENT_BLOCKER;
export const LIMITATION =
  "The public-alpha contract defines one synthetic MCP sandbox. Bulla controls the authorization, receiver, denominator, witness, and publication keys. A deployment establishes execution across path-separated services; it does not establish customer authority, denominator completeness, organizational independence, production safety, or incident truth.";

export interface Env {
  CONTROL_PLANE_RUN: DurableObjectNamespace;
  SYNTHETIC_RECEIVER: DurableObjectNamespace;
  RECEIPT_WITNESS: DurableObjectNamespace;
  PROFILE: typeof SERVICE_PROFILE;
  INCIDENT_PACKET_PROFILE: typeof PROFILE;
  MATURITY: typeof MATURITY;
  DISTRIBUTION: typeof DISTRIBUTION;
  MCP_PROTOCOL_PIN: string;
  DEPLOYMENT_GATE: typeof DEPLOYMENT_GATE;
  RETIREMENT_EXPORT_GATE:
    | "BLOCKED_OPERATOR_EXPORT_NOT_IMPLEMENTED"
    | "PASSED";
  KEY_ROTATION_RETIREMENT_GATE:
    | "BLOCKED_KEY_ROTATION_RETIREMENT_NOT_IMPLEMENTED"
    | "PASSED";
  TRANSACTION_RECONCILER_GATE:
    | "BLOCKED_EXTERNAL_RECONCILER_NOT_IMPLEMENTED"
    | "PASSED";
  PRODUCTION_DEPLOYMENT_BLOCKED: "true" | "false";
  KEY_PROVIDER_MODE:
    | "EPHEMERAL_LOCAL_ONLY"
    | "PROVISIONED_JWK"
    | "RECOVERY_PUBLIC_READ_ONLY";
  AUTHORIZATION_SIGNING_JWK?: string;
  RECEIVER_SIGNING_JWK?: string;
  DENOMINATOR_SIGNING_JWK?: string;
  INCIDENT_COMMANDER_SIGNING_JWK?: string;
  WITNESS_SIGNING_JWK?: string;
  PUBLICATION_SIGNING_JWK?: string;
  CAPABILITY_TOKEN_SECRET?: string;
  ALLOWED_ORIGINS: string;
  TRUST_CONTEXT_REF: string;
  TRUST_CONTEXT_SHA256: string;
  BUILD_COMMIT: string;
  CF_VERSION_METADATA: {
    id: string;
    tag: string;
    timestamp: string;
  };
  CREATE_RATE_LIMITER: RateLimit;
  MUTATE_RATE_LIMITER: RateLimit;
}

interface RateLimit {
  limit(options: { key: string }): Promise<{ success: boolean }>;
}

export {
  HttpError,
  type CoverageDimension,
  type CoverageReport,
  type JsonObject,
  type JsonPrimitive,
  type JsonValue,
  type Proof,
  type SignerMaterial,
} from "./browser-types";
import type { JsonValue } from "./browser-types";

export interface PacketMember {
  path: string;
  media_type: "application/json";
  byte_length: number;
  sha256: string;
}
