/**
 * Gateway-facing Agent RPC type contract.
 *
 * This file defines the typed `AgentCall` signature that Gateway consumers use
 * to invoke Agent RPC methods with full compile-time safety.
 *
 * Design: Gateway only needs the "shape" of params/result for the methods it
 * actually calls. Internal-only methods (agent internals) are not exposed here.
 *
 * Reference: CC uses Zod union in a single package; we use TypeScript interface map
 * in a shared package (same effect — single source, compile-time checked).
 */
export type ProjectType = "default" | "personal" | "group" | "solo" | "product" | "automation";
export type ProjectStatus = "active" | "archived";
export interface LocalizedTextWire {
    key: string;
    fallback: string;
    values?: Record<string, string>;
}
export type CapabilityCategoryWire = "orchestration" | "filesystem" | "web" | "search" | "memory" | "media" | "developer" | "mcp" | "automation" | "system" | "other";
export interface ProjectInfo {
    id: string;
    name: string;
    workspaceDir: string;
    type: ProjectType;
    status: ProjectStatus;
    groupId?: string;
    createdAt: string;
    updatedAt: string;
    planStatus?: "creating" | "running" | "completed" | "failed" | "cancelled";
    planAgents?: string[];
    planWinnerId?: string;
    leaderSessionId?: string;
    primaryWorkflowId?: string;
}
export interface MemoryAttachmentWire {
    type: "image" | "audio" | "video" | "file" | string;
    filename: string;
    mimeType?: string;
    size?: number;
    text?: string;
    url?: string;
    path?: string;
}
export interface MemoryCandidateWire {
    id?: string;
    text: string;
    category?: string;
    importance?: number;
    confidence?: number;
    source?: string;
    eventDate?: string;
    tags?: string[];
    relatedMemoryIds?: string[];
    evidence?: Array<Record<string, unknown>>;
    requiresConfirmation?: boolean;
    reason?: string;
}
export interface MemoryTextMutationParams {
    text?: string;
    category?: string;
    importance?: number;
    source?: string;
    tags?: string[];
    attachments?: MemoryAttachmentWire[];
    autoExtract?: boolean;
}
export interface MemoryConsolidationResult {
    ok: boolean;
    memoriesAdded: number;
    observationsAdded?: number;
    proposalsAdded?: number;
    claimsAdded?: number;
    conflictsAdded?: number;
    claimIds?: string[];
    conflictIds?: string[];
}
export interface GatewayRpcMethodMap {
    "agent.health": {
        params: {};
        result: {
            ok: boolean;
            status: "healthy" | "degraded" | "stopping";
            uptimeMs: number;
            protocolVersion: string;
            version: string;
        };
    };
    "agent.metrics": {
        params: {};
        result: {
            rpc: {
                activeRequests: number;
                completedRequests: number;
                cancelledRequests: number;
                deadlineExceededRequests: number;
                dedupedRequests: number;
                lateResponsesDropped: number;
                invalidRequests: number;
            };
        };
    };
    "agent.cancel": {
        params: {
            requestId: string;
            reason?: string;
        };
        result: {
            ok: boolean;
            cancelled: boolean;
        };
    };
    "session.list": {
        params: {
            limit?: number;
            projectId?: string;
            archived?: boolean;
        };
        result: {
            sessions: Array<{
                sessionId: string;
                title?: string;
                type?: string;
                groupKey?: string;
                groupPlatform?: string;
                lastActiveAt?: string;
                messageCount: number;
                pinnedAt?: string | null;
                archivedAt?: string | null;
                projectId: string;
            }>;
        };
    };
    "session.get": {
        params: {
            sessionId: string;
        };
        result: {
            session: {
                sessionId: string;
                title?: string;
                type?: string;
                groupKey?: string;
                groupPlatform?: string;
                lastActiveAt?: string;
                messageCount?: number;
                pinnedAt?: string | null;
                archivedAt?: string | null;
            } | null;
        };
    };
    "session.create": {
        params: {
            sessionId?: string;
            title?: string;
            type?: string;
            ownerPlatform?: string;
            ownerId?: string;
            groupKey?: string;
            groupName?: string;
            groupPlatform?: string;
            projectId?: string;
            projectName?: string;
        };
        result: {
            ok: boolean;
            sessionId?: string;
        };
    };
    "session.update": {
        params: {
            sessionId: string;
            title?: string;
            pinnedAt?: string | null;
            archivedAt?: string | null;
        };
        result: {
            ok: boolean;
        };
    };
    "session.delete": {
        params: {
            sessionId: string;
            projectId: string;
        };
        result: {
            ok: boolean;
        };
    };
    "session.deleteAll": {
        params: {
            projectId: string;
        };
        result: {
            ok: boolean;
            deletedCount: number;
        };
    };
    "session.archive": {
        params: {
            sessionId: string;
        };
        result: {
            ok: boolean;
        };
    };
    "session.moveToProject": {
        params: {
            sessionId: string;
            fromProjectId: string;
            toProjectId: string;
        };
        result: {
            ok: boolean;
        };
    };
    "session.getState": {
        params: Record<string, never>;
        result: {
            sessionId: string;
            activeProject: ProjectInfo | null;
            projects: ProjectInfo[];
        };
    };
    "session.switchProject": {
        params: {
            projectId?: string;
            projectName?: string;
            workspaceDir?: string;
        };
        result: {
            ok: boolean;
            project: ProjectInfo;
        };
    };
    "session.getMessages": {
        params: {
            sessionId?: string;
            limit?: number;
        };
        result: {
            messages: unknown[];
            total: number;
        };
    };
    "project.list": {
        params: Record<string, never>;
        result: {
            projects: ProjectInfo[];
        };
    };
    "project.create": {
        params: {
            name: string;
            workspaceDir?: string;
            type?: ProjectType;
            groupId?: string;
        };
        result: {
            ok: boolean;
            project?: ProjectInfo;
            error?: string;
            deduplicated?: boolean;
        };
    };
    "project.delete": {
        params: {
            projectId: string;
        };
        result: {
            ok: boolean;
            switchedTo?: ProjectInfo;
        };
    };
    "project.rename": {
        params: {
            projectId: string;
            newName: string;
        };
        result: {
            ok: boolean;
            project?: ProjectInfo;
        };
    };
    "project.archive": {
        params: {
            projectId: string;
        };
        result: {
            ok: boolean;
        };
    };
    "project.unarchive": {
        params: {
            projectId: string;
        };
        result: {
            ok: boolean;
        };
    };
    "project.update": {
        params: {
            projectId: string;
            planStatus?: "creating" | "running" | "completed" | "failed" | "cancelled";
            planAgents?: string[];
            planWinnerId?: string;
            leaderSessionId?: string;
            primaryWorkflowId?: string;
        };
        result: {
            ok: boolean;
        };
    };
    "project.archiveByGroup": {
        params: {
            platform: string;
            chatId: string;
        };
        result: {
            ok: boolean;
            projectId?: string;
        };
    };
    "project.purgeAll": {
        params: Record<string, never>;
        result: {
            ok: boolean;
            deletedCount?: number;
        };
    };
    "instructions.list": {
        params: {
            projectId?: string;
        };
        result: {
            instructions: Array<{
                path: string;
                name: string;
                size: number;
            }>;
        };
    };
    "instructions.read": {
        params: {
            projectId?: string;
            path: string;
        };
        result: {
            content: string;
            path: string;
        };
    };
    "instructions.write": {
        params: {
            projectId?: string;
            path: string;
            content: string;
        };
        result: {
            ok: boolean;
        };
    };
    "instructions.delete": {
        params: {
            projectId?: string;
            path: string;
        };
        result: {
            ok: boolean;
        };
    };
    "files.list": {
        params: {
            projectId: string;
            path?: string;
        };
        result: {
            entries: Array<{
                name: string;
                path: string;
                type: "file" | "directory";
                size?: number;
                modifiedAt?: string;
            }>;
        };
    };
    "files.read": {
        params: {
            projectId: string;
            path: string;
        };
        result: {
            path: string;
            content: string;
            encoding?: string;
        };
    };
    "files.create": {
        params: {
            projectId: string;
            path: string;
            type?: "file" | "directory";
            content?: string;
        };
        result: {
            ok: boolean;
            path: string;
        };
    };
    "files.rename": {
        params: {
            projectId: string;
            oldPath: string;
            newName: string;
        };
        result: {
            ok: boolean;
            newPath?: string;
        };
    };
    "files.delete": {
        params: {
            projectId: string;
            path: string;
        };
        result: {
            ok: boolean;
        };
    };
    "files.gitStatus": {
        params: {
            projectId: string;
        };
        result: {
            files: Array<{
                path: string;
                status: string;
            }>;
        };
    };
    "skills.list": {
        params: {
            projectId?: string;
        };
        result: {
            skills: Array<{
                id: string;
                name: string;
                path: string;
                active: boolean;
                scope: "project" | "global";
                category: CapabilityCategoryWire;
                displayName: LocalizedTextWire;
                displayDescription: LocalizedTextWire;
                fallbackName: string;
                fallbackDescription: string;
                systemGenerated: boolean;
                version?: string;
                description?: string;
            }>;
        };
    };
    "memory.list-files": {
        params: {
            projectId?: string;
        };
        result: {
            files: Array<{
                name: string;
                path: string;
                size?: number;
            }>;
        };
    };
    "memory.atlas": {
        params: {
            pageSize?: number;
            windowStartAt?: number;
            windowEndAt?: number;
            windowCenterAt?: number;
            bucketCount?: number;
            clusterLimit?: number;
        };
        result: {
            totalCount: number;
            records: Array<{
                id: string;
                text: string;
                category: string;
                importance: number;
                confidence: number;
                source: string;
                sessionId: string;
                eventDate: string;
                tags: string[];
                createdAt: number;
                updatedAt: number;
                accessCount: number;
                lastAccessedAt: number;
                isArchived: boolean;
            }>;
            buckets: Array<{
                id: string;
                startAt: number;
                endAt: number;
                count: number;
                avgImportance: number;
                avgConfidence: number;
                topCategory: string;
            }>;
            clusters: Array<{
                id: string;
                label: string;
                kind: "source" | "category" | "tag";
                count: number;
                startAt: number;
                endAt: number;
                avgImportance: number;
                avgConfidence: number;
                topCategory: string;
            }>;
            windowCursor: {
                startAt: number;
                endAt: number;
                centerAt: number;
                pageSize: number;
                hasBefore: boolean;
                hasAfter: boolean;
            } | null;
            timeRange: {
                startAt: number;
                endAt: number;
            } | null;
            stats: {
                formed: number;
                insights: number;
                preferences: number;
            };
        };
    };
    "memory.activity": {
        params: {
            days?: number;
        };
        result: {
            dailyCounts: Array<{
                date: string;
                count: number;
            }>;
            highlights: Array<{
                id: string;
                text: string;
                category: string;
                importance: number;
                date: string;
            }>;
        };
    };
    "memory.observe": {
        params: {
            text: string;
            category?: string;
            importance?: number;
            source?: string;
            tags?: string[];
        };
        result: {
            ok: boolean;
            observationsAdded: number;
            observationIds: string[];
        };
    };
    "memory.propose": {
        params: MemoryTextMutationParams;
        result: {
            ok: boolean;
            extractor?: "llm" | "deterministic";
            candidates: MemoryCandidateWire[];
            relatedMemories?: Array<{
                id: string;
                text: string;
                score: number;
                category?: string;
            }>;
            observationsAdded: number;
            proposalsAdded: number;
            observationIds: string[];
            proposalIds: string[];
        };
    };
    "memory.consolidate": {
        params: MemoryTextMutationParams & {
            candidates?: MemoryCandidateWire[];
        };
        result: MemoryConsolidationResult;
    };
    "memory.update": {
        params: {
            id: string;
            text?: string;
            category?: string;
            importance?: number;
            source?: string;
            eventDate?: string;
            tags?: string[];
        };
        result: {
            ok: boolean;
            updated: number;
        };
    };
    "memory.attachment.adopt": {
        params: {
            tempUrl: string;
            filename?: string;
            mimeType?: string;
        };
        result: {
            ok: boolean;
            attachment?: {
                id: string;
                kind: string;
                filename: string;
                mimeType: string;
                size: number;
                url: string;
            };
        };
    };
    "memory.attachment.locate": {
        params: {
            id: string;
        };
        result: {
            ok: boolean;
            absPath?: string;
            mimeType?: string;
            filename?: string;
        };
    };
}
/**
 * Type-safe Agent RPC caller.
 * Gateway passes this around instead of `(string, Record<string, unknown>) => Promise<unknown>`.
 */
export interface AgentCallOptions {
    timeoutMs?: number;
    requestId?: string;
    idempotencyKey?: string;
    traceId?: string;
}
export type AgentCall = <M extends keyof GatewayRpcMethodMap>(method: M, params: GatewayRpcMethodMap[M]["params"], options?: AgentCallOptions) => Promise<GatewayRpcMethodMap[M]["result"]>;
/** All gateway-facing RPC method names (runtime array). */
export declare const GATEWAY_RPC_METHODS: (keyof GatewayRpcMethodMap)[];
