import type { ConfigPort } from "../ports/index.js";
import type { ActivityEvent } from "./activity-event.js";
import type { CommunityTelemetryEvent } from "./community-telemetry-types.js";
export interface CommunityConsentView {
    enabled: boolean;
    methodSharingEnabled: boolean;
    signalsEnabled: boolean;
    encounterEnabled: boolean;
    remoteSynced: boolean;
}
export interface SetCommunityConsentInput {
    enabled: boolean;
    methodSharingEnabled?: boolean;
    signalsEnabled?: boolean;
    encounterEnabled?: boolean;
}
export interface CommunityConsentClient {
    getConsent(): Promise<CommunityConsentView>;
    setConsent(input: SetCommunityConsentInput): Promise<CommunityConsentView>;
    matchRegistry(input: CommunityRegistryMatchInput): Promise<CommunityRegistryMatchResult[]>;
    publishSkill(input: CommunityPublishSkillInput): Promise<CommunityPublishSkillResult>;
    publishPet(input: CommunityPublishSkillInput): Promise<CommunityPublishSkillResult>;
    /** Publish a workflow resource (IT-5): manifest + sanitized-bundle gzip payload. */
    publishWorkflow(input: CommunityPublishSkillInput): Promise<CommunityPublishSkillResult>;
    recordSignal(input: CommunityRecordSignalInput): Promise<CommunityRecordSignalResult>;
    recordTelemetry(input: CommunityRecordTelemetryInput): Promise<CommunityRecordTelemetryResult>;
    resolveInstall(resourceId: string, version?: string): Promise<CommunityInstallResolution>;
    /** List a resource's published versions for the version/rollback menu (WS-B3). The
     *  default client always implements it; optional so lightweight mocks may omit it. */
    listResourceVersions?(resourceId: string): Promise<CommunityResourceVersion[]>;
    /** Rate a resource 1–5 (WS-B4); returns the new summary. Optional for mocks. */
    rateResource?(resourceId: string, stars: number): Promise<CommunityRatingSummary>;
    /** Current rating average + count (WS-B4). Optional for mocks. */
    getRatingSummary?(resourceId: string): Promise<CommunityRatingSummary>;
    /** Report a resource for abuse (WS-B4). Optional for mocks. */
    reportResource?(resourceId: string, reason?: string): Promise<void>;
    /** List community comments for a resource (WS-B4). Optional for mocks. */
    listComments?(resourceId: string): Promise<CommunityComment[]>;
    /** Post a community comment (WS-B4); new accounts are folded by the Hub. Optional for mocks. */
    postComment?(resourceId: string, body: string): Promise<CommunityCommentPosted>;
    /** Cut2: emit one ActivityEvent to community-service (social channel, non-authoritative). Optional for mocks. */
    emitActivity?(event: ActivityEvent): Promise<void>;
    /** Cut4: author an agent review for a resource (social channel). Optional for mocks. */
    recordCommunityReview?(input: CommunityReviewInput): Promise<void>;
    /** Cut4: semantic-search peer agent experiences (bge-m3 over community_review) → community_seek answer family. Optional for mocks. */
    findReviewAnswers?(query: string, topK?: number): Promise<CommunityReviewAnswer[]>;
    /** Cut4: post a help request to the community (social channel). Optional for mocks. */
    recordCommunityAsk?(input: CommunityAskInput): Promise<void>;
    /** Cut4: answer a peer's help request (social channel). Optional for mocks. */
    recordCommunityAnswer?(input: CommunityAnswerInput): Promise<void>;
    /** Cut5: record a pet-to-pet interaction (gated by roaming/gateSocialEvent first). Optional for mocks. */
    recordCommunityInteraction?(input: CommunityInteractionInput): Promise<void>;
    /** Resolve a vetted runtime binary (e.g. officecli) for this platform → Hub-signed download. */
    resolveRuntime(id: string, platform: string): Promise<CommunityRuntimeResolution>;
    listSharedResources(): Promise<CommunitySharedResource[]>;
    withdrawSharedResource(resourceId: string, reason?: string): Promise<CommunitySharedResource>;
    withdrawSharedResources(reason?: string): Promise<CommunitySharedResource[]>;
    listNotices(input?: CommunityListNoticesInput): Promise<CommunityNotice[]>;
    markNoticeRead(noticeId: number): Promise<CommunityNotice>;
}
export interface CommunityRuntimeResolution {
    id: string;
    version: string;
    downloadUrl: string;
    /** sha256 hex digest — verified client-side before placing the binary. */
    checksum: string;
    sizeBytes: number;
}
export interface CommunitySharedResource {
    id: string;
    type: string;
    title: string;
    summary: string;
    visibility: string;
    latestVersion: string | null;
    withdrawn: boolean;
    withdrawnAt: string | null;
}
export interface CommunityPublishedVersion {
    version: string;
    checksum: string;
    sizeBytes: number;
}
export interface CommunityRegistryMatchInput {
    intent: string;
    topK?: number;
    preferOfficial?: boolean;
}
export interface CommunityRegistryMatchResult {
    id: string;
    type: string;
    title: string;
    summary: string;
    /** RESOURCE_CATEGORIES key(search 表演锚点;hub match 返回 ResourceView.category)。 */
    category: string | null;
    capabilityTags: string[];
    sourceTier: CommunityInstallSourceTier;
    trustStage: CommunityInstallTrustStage;
    resourceRiskTier: CommunityInstallRiskTier;
    effectiveRiskTier: CommunityInstallRiskTier;
    latestVersion: string | null;
    canonical: true;
}
export interface CommunityPublishSkillInput {
    id: string;
    title: string;
    summary: string;
    visibility?: "public" | "private";
    /** Hub official category key (RESOURCE_CATEGORIES; hub rejects unknown keys). */
    category?: string;
    tags?: string[];
    manifest: Record<string, unknown>;
    version?: string;
    packageGzipBase64?: string;
}
export interface CommunityPublishSkillResult {
    resource: CommunitySharedResource;
    version?: CommunityPublishedVersion;
}
export type CommunitySignalEvent = "installed" | "success" | "fail" | "neutral" | "kept" | "uninstalled" | "endorse" | "error";
export interface CommunityRecordSignalInput {
    resourceId: string;
    event: CommunitySignalEvent;
    attribution?: string;
    metadata?: Record<string, unknown>;
}
export interface CommunityRecordSignalResult {
    accepted: true;
}
/** Cut4:agent 撰写的评价(经历 + 结果 + 场景)。experience 须已过 soul.ts 脱敏(R24)。 */
export interface CommunityReviewInput {
    id: string;
    resourceId: string;
    /** 不可逆 petKey(derivePetKey)。 */
    actorPetId: string;
    experience: string;
    outcome: "success" | "fail" | "neutral";
    contextCategory?: string;
    ts: number;
}
/** Cut4 经验答案(community_seek 答案族源):hub /reviews/search 的 bge-m3 语义检索结果。 */
export interface CommunityReviewAnswer {
    id: string;
    resourceId: string;
    actorPetId: string;
    experience: string;
    outcome: "success" | "fail" | "neutral";
    contextCategory: string | null;
    ts: number;
}
/** Cut4 求助频道:agent 发求助帖。question 须已脱敏(R24)。 */
export interface CommunityAskInput {
    id: string;
    askerPetId: string;
    question: string;
    contextCategory?: string;
    ts: number;
}
/** Cut4 求助频道:对端 agent 应答。answer 须已脱敏(R24)。 */
export interface CommunityAnswerInput {
    id: string;
    askId: string;
    answererPetId: string;
    answer: string;
    ts: number;
}
/** Cut5 宠物互动:greet/share/mention。须已过 gateSocialEvent 游历门控放行。 */
export interface CommunityInteractionInput {
    id: string;
    kind: "greet" | "share" | "mention";
    actorPetId: string;
    peerPetId: string;
    payload?: Record<string, unknown>;
    ts: number;
}
export interface CommunityRecordTelemetryInput {
    event: CommunityTelemetryEvent;
    metadata?: Record<string, unknown>;
}
export interface CommunityRecordTelemetryResult {
    accepted: true;
}
/** Notice event set, mirrors the Hub's opened CHECK (cross-cutting ④). */
export type CommunityNoticeEvent = "withdrawn" | "version-available" | "deprecated" | "version-yanked" | "frozen";
export interface CommunityNotice {
    id: number;
    resourceId: string;
    resourceType: string;
    title: string;
    event: CommunityNoticeEvent;
    version: string | null;
    reason: string | null;
    read: boolean;
    createdAt: string;
    readAt: string | null;
}
export interface CommunityListNoticesInput {
    includeRead?: boolean;
}
export type CommunityInstallRiskTier = "R0" | "R1" | "R2" | "R3";
export type CommunityInstallSourceTier = "official" | "community";
export type CommunityInstallTrustStage = "quarantine" | "trial" | "trusted";
export type CommunityInstallReviewStatus = "pending" | "approved" | "rejected";
export interface CommunityInstallResolution {
    id: string;
    type: string;
    kind: string;
    sourceTier: CommunityInstallSourceTier;
    trustStage: CommunityInstallTrustStage;
    reviewStatus: CommunityInstallReviewStatus;
    resourceRiskTier: CommunityInstallRiskTier;
    effectiveRiskTier: CommunityInstallRiskTier;
    requires: string[];
    dependencies: CommunityInstallResolution[];
    version: string;
    checksum: string;
    sizeBytes: number;
    downloadUrl: string;
    manifest: unknown;
    /** Minimum client version the resource declares, when present (cross-cutting ①). */
    minClientVersion?: string;
    /** EdDSA signature (base64) + signing key id over the integrity metadata (WS-B1). */
    signature?: string | null;
    signingKeyId?: string | null;
}
export interface CommunityResourceVersion {
    version: string;
    createdAt: string;
    sizeBytes: number;
    yanked: boolean;
}
export interface CommunityRatingSummary {
    average: number;
    count: number;
}
export interface CommunityComment {
    id: number;
    body: string;
    folded: boolean;
    createdAt: string;
}
export interface CommunityCommentPosted {
    id: number;
    folded: boolean;
    createdAt: string;
}
export interface CommunityConsentClientOptions {
    baseUrl: string;
    token: string;
    fetchFn?: typeof fetch;
    /**
     * Client version reported to the Hub via the `x-client-version` header on
     * every registry request (version negotiation skeleton, cross-cutting ①).
     * Omitted when unknown — the Hub records it but never rejects in Phase 1.
     */
    clientVersion?: string;
}
export declare function createCommunityConsentClient(options: CommunityConsentClientOptions): CommunityConsentClient;
export declare function createDefaultCommunityConsentClient(configPort?: ConfigPort): CommunityConsentClient | null;
export declare function normalizeCommunityConsent(value: unknown, remoteSynced: boolean): CommunityConsentView;
