/**
 * ReplitAgentAdapter -- Replit Agent IDE adapter.
 *
 * Replit is a browser-based IDE with full sandbox execution. The Replit Agent
 * is an AI system that operates INSIDE the Repl environment: it can plan and
 * execute tasks, run code, manipulate files, install packages, deploy to
 * Replit Deployments, access Replit Secrets, and query databases -- all
 * autonomously.
 *
 * Replit's user base is the most diverse in the Connexum catalogue: students,
 * hobbyists, indie developers, small teams, and early-stage startups. This
 * diversity creates governance challenges unique to Replit:
 *   - Minor / student users require extra protection (COPPA, FERPA concerns).
 *   - High-volume signup means credentials are frequently mishandled.
 *   - Supply-chain risk is elevated because students copy-paste package installs.
 *   - Replit Deployments are production-facing changes triggered from a browser
 *     -- no separate CI/CD layer means the governance gate IS the last line.
 *
 * Deployment modes:
 *   replit-cloud        -- Replit-managed SaaS (default). Individual Repls.
 *   replit-teams        -- Replit Teams for Education or business orgs.
 *                          Governed multi-user workspace.
 *   replit-deployments  -- Replit Deployments (production-facing). The only
 *                          mode where wrapDeployment is permitted by default.
 *
 * Hook surfaces (eight distinct governable surfaces):
 *
 *   agentTaskRequested(taskDescription)
 *     High-level natural language task gate ("build a flask app that...").
 *     REQUIRES a non-empty taskDescription for auditability.
 *     Reason code: replit-agent-task-description-required.
 *
 *   sandboxCodeExecutionRequested(code, language)
 *     Execute code in the Repl sandbox. Scans for network-egress patterns.
 *     For minor users: egress patterns cause DENIAL.
 *     For non-minor: egress patterns produce an audit warning (allowed).
 *
 *   fileSystemMutationRequested(files[])
 *     Create / modify / delete files in the Repl. Blast-radius cap enforced:
 *     file count > multiFileEditCap (default 25) = DENIED.
 *     Replit's default is 25 (higher than other IDEs because file mutations
 *     are Replit's core agentic surface).
 *
 *   packageInstallRequested(packageName, manager)
 *     Install npm/pip/etc. dependencies. Carries network-egress + supply-chain
 *     risk. Guards:
 *       - minor + student: DENIED unconditionally.
 *       - packageInstallAllowList[] configured: only listed packages allowed.
 *       - typosquat heuristics: package names > 40 chars or containing
 *         unusual punctuation are flagged.
 *
 *   deploymentRequested(target, branch)
 *     Replit Deployments push (production-facing change). CRITICAL surface.
 *     Guards:
 *       - userIsMinor: true -> ALWAYS DENIED.
 *       - userTier: 'student' -> ALWAYS DENIED.
 *       - deploymentMode !== 'replit-deployments' AND allowDeployment !== true
 *         -> DENIED (only the deployments mode or explicit opt-in allows deploys).
 *
 *   secretAccessRequested(secretName)
 *     Replit Secrets manager read. HIGH SENSITIVITY.
 *     Guards:
 *       - userIsMinor: true -> ALWAYS DENIED.
 *       - allowSecretAccess !== true -> DENIED.
 *
 *   databaseQueryRequested(query, dbType)
 *     Replit DB / hosted DB query. Scanned for destructive SQL patterns.
 *
 *   chatRequested(prompt)
 *     Replit Agent chat. Scanned for secrets and PHI.
 *
 * Minor / student safeguards (the Replit-distinct differentiators):
 *   - userIsMinor: true OR userTier: 'student' triggers strict defaults:
 *       - deployment: ALWAYS DENIED
 *       - secret access: ALWAYS DENIED (minor) / requires opt-in (student)
 *       - package install: DENIED (minor+student combo)
 *   - userAge: 'minor' is an alias for userIsMinor: true (legacy compat)
 *
 * Pen-tests:
 *   PT-ADAPT-REPLIT-1: empty packBinding[] denied at every wrap call
 *   PT-ADAPT-REPLIT-2: Replit auth token never appears in audit entries
 *   PT-ADAPT-REPLIT-3: malformed config throws at construction (invalid mode,
 *                      negative cap, userIsMinor + userTier='admin')
 *   PT-ADAPT-REPLIT-4: minor + deployment attempt always denied with
 *                      replit-deployment-not-permitted-minor
 *   PT-ADAPT-REPLIT-5: minor + secret access always denied with
 *                      replit-secret-access-not-permitted
 *   PT-ADAPT-REPLIT-6: package install allowList enforcement audit entry
 *                      contains the offending package name (sanitized)
 *
 * Spec: P3-SUB-IDE-13
 *
 * @connexum/ai-governance
 */
import { BaseIdeAdapter } from './base';
import { type IdeAdapterConfig, type IdeAdapterCapabilities, type IdeSessionContext, type ToolInvocationContext, type ToolInvocationDecision, type UserIdentity, type ReviewerTier } from './index';
/**
 * Replit deployment modes.
 *
 *   replit-cloud        -- Replit-managed SaaS. Default for individuals.
 *   replit-teams        -- Replit Teams (Education or business org).
 *                          Multi-user governed workspace.
 *   replit-deployments  -- Replit Deployments. Production-facing changes.
 *                          The only mode where wrapDeployment is enabled by
 *                          default (without requiring allowDeployment: true).
 */
export type ReplitDeploymentMode = 'replit-cloud' | 'replit-teams' | 'replit-deployments';
export declare const REPLIT_VALID_DEPLOYMENT_MODES: readonly ReplitDeploymentMode[];
/** BAA-eligible modes (Replit Teams has an enterprise BAA path). */
export declare const REPLIT_BAA_ELIGIBLE_MODES: readonly ReplitDeploymentMode[];
/** User tiers supported by Replit. */
export type ReplitUserTier = 'student' | 'individual' | 'team-member' | 'admin';
export declare const REPLIT_VALID_USER_TIERS: readonly ReplitUserTier[];
export interface ReplitSandboxResourceCap {
    /** Maximum CPU seconds for a single sandbox execution. Advisory only. */
    maxCpuSeconds?: number;
    /** Maximum memory in MiB for a single sandbox execution. Advisory only. */
    maxMemoryMb?: number;
}
export interface ReplitAgentAdapterConfig extends IdeAdapterConfig {
    /**
     * Replit deployment mode. Required. No default.
     * Determines deployment permission defaults and team-governance posture.
     */
    deploymentMode: ReplitDeploymentMode;
    /**
     * User tier. Optional. Affects strict-mode defaults.
     *   'student' -- blocks deployment; restricts package install.
     *   'individual' -- standard controls.
     *   'team-member' -- standard controls in team context.
     *   'admin' -- administrative access (still subject to minor guard).
     *
     * Invariant: userTier: 'admin' AND userIsMinor: true is a logical
     * inconsistency -- minors cannot be admins. Throws at construction.
     */
    userTier?: ReplitUserTier;
    /**
     * Minor user flag. Default: false.
     * When true, activates strict educational safeguards:
     *   - Deployment ALWAYS DENIED.
     *   - Secret access ALWAYS DENIED.
     *   - Package install DENIED when userTier is also 'student'.
     * COPPA / FERPA compliance concern: minors must not access production
     * secrets or trigger production deployments from the IDE.
     */
    userIsMinor?: boolean;
    /**
     * Explicit opt-in to allow deployment operations.
     * Default: true only in 'replit-deployments' mode; false otherwise.
     * No effect when userIsMinor: true (always denied for minors).
     */
    allowDeployment?: boolean;
    /**
     * Explicit opt-in to allow Replit Secrets access.
     * Default: false (governance default-deny).
     * No effect when userIsMinor: true (always denied for minors).
     */
    allowSecretAccess?: boolean;
    /**
     * Allow package installation. Default: true (Replit's primary workflow).
     * Automatically set to false for minor+student users regardless of this flag.
     */
    allowPackageInstall?: boolean;
    /**
     * When configured, restricts package installs to only listed package names.
     * Any install attempt for a package NOT in this list is DENIED.
     * Useful in team / education environments to enforce an approved package set.
     */
    packageInstallAllowList?: string[];
    /**
     * Sandbox resource advisory caps. Governance records these; enforcement
     * is the Replit platform's responsibility.
     */
    sandboxResourceCap?: ReplitSandboxResourceCap;
    /**
     * Maximum number of files that may be mutated in a single fileSystemMutation
     * operation. Default: 25 (Replit default is higher than other IDEs because
     * file mutations are Replit's core agentic surface).
     * Must be a positive integer.
     */
    multiFileEditCap?: number;
    /** Reviewer tier for HIPAA-bound PHI gate. Default: T2_LEAD */
    hipaaReviewerTier?: ReviewerTier;
}
export interface ReplitAgentTaskContext {
    /** High-level natural language description of the task. REQUIRED. */
    taskDescription: string;
    sessionId?: string;
}
export interface ReplitSandboxCodeExecutionContext {
    /** Code to execute in the Repl sandbox. */
    code: string;
    /** Programming language identifier (e.g. 'python', 'javascript', 'bash'). */
    language?: string;
    sessionId?: string;
}
export interface ReplitFileSystemMutationContext {
    /** Files to create / modify / delete. */
    files: string[];
    /** Brief description of the mutation intent. */
    description?: string;
    sessionId?: string;
}
export interface ReplitPackageInstallContext {
    /** Package name to install. */
    packageName: string;
    /** Package manager (e.g. 'npm', 'pip', 'yarn', 'cargo'). */
    manager?: string;
    sessionId?: string;
}
export interface ReplitDeploymentContext {
    /** Deployment target (e.g. 'production', 'staging'). */
    target?: string;
    /** Branch or commit to deploy. */
    branch?: string;
    sessionId?: string;
}
export interface ReplitSecretAccessContext {
    /** Name of the secret being accessed. */
    secretName: string;
    sessionId?: string;
}
export interface ReplitDatabaseQueryContext {
    /** SQL or database query string. */
    query: string;
    /** Database type identifier (e.g. 'postgresql', 'sqlite', 'replit-db'). */
    dbType?: string;
    sessionId?: string;
}
export interface ReplitChatContext {
    promptText: string;
    sessionId?: string;
}
export declare class ReplitAgentAdapter extends BaseIdeAdapter {
    readonly adapterId = "replit-agent";
    readonly ideId = "replit-agent";
    private replitConfig;
    initialize(config: IdeAdapterConfig): void;
    resolveUserIdentity(session: IdeSessionContext): Promise<UserIdentity>;
    interceptToolInvocation(ctx: ToolInvocationContext): Promise<ToolInvocationDecision>;
    private _gateAgentTaskRequest;
    private _gateSandboxCodeExecutionRequest;
    private _gateFileSystemMutationRequest;
    private _gatePackageInstallRequest;
    private _gateDeploymentRequest;
    private _gateSecretAccessRequest;
    private _gateDatabaseQueryRequest;
    private _gateChatRequest;
    wrapAgentTask(ctx: ReplitAgentTaskContext): Promise<ToolInvocationDecision>;
    wrapSandboxCodeExecution(ctx: ReplitSandboxCodeExecutionContext): Promise<ToolInvocationDecision>;
    wrapFileSystemMutation(ctx: ReplitFileSystemMutationContext): Promise<ToolInvocationDecision>;
    wrapPackageInstall(ctx: ReplitPackageInstallContext): Promise<ToolInvocationDecision>;
    wrapDeployment(ctx: ReplitDeploymentContext): Promise<ToolInvocationDecision>;
    wrapSecretAccess(ctx: ReplitSecretAccessContext): Promise<ToolInvocationDecision>;
    wrapDatabaseQuery(ctx: ReplitDatabaseQueryContext): Promise<ToolInvocationDecision>;
    wrapChat(ctx: ReplitChatContext): Promise<ToolInvocationDecision>;
    getIdeCapabilities(): IdeAdapterCapabilities;
    translateError(raw: unknown): import('./index').IdeAdapterError;
    getDeploymentMode(): ReplitDeploymentMode;
    getUserTier(): ReplitUserTier;
    isMinorUser(): boolean;
    getMultiFileEditCap(): number;
    isSecretAccessAllowed(): boolean;
    private _isDeploymentAllowed;
    private _scanForSecrets;
    private _scanForPhi;
    private _isHipaaBinding;
}
//# sourceMappingURL=replit-agent.d.ts.map