import { z } from 'zod';

/**
 * Context passed to all DataSource operations
 * Contains internal state that should not be mixed with user query parameters
 */
interface BaseDataSourceContext {
    /**
     * Whether to filter to only published/complete content
     * Set by site-builder: true for production, false for preview
     */
    publishedOnly?: boolean;
    /**
     * Scoped entity service that auto-applies publishedOnly filter
     * Datasources should use this instead of their injected entityService
     * to ensure consistent filtering behavior across environments
     */
    entityService: EntityService;
}
/**
 * DataSource Interface
 *
 * Provides data for templates through fetch, generate, or transform operations.
 * DataSources are registered in the DataSourceRegistry and referenced by templates
 * via their dataSourceId property.
 */
interface DataSource {
    /**
     * Unique identifier for this data source
     */
    id: string;
    /**
     * Human-readable name for this data source
     */
    name: string;
    /**
     * Optional description of what this data source provides
     */
    description?: string;
    /**
     * Optional: Fetch existing data
     * Used by data sources that aggregate or retrieve data (e.g., dashboard stats, API data)
     * DataSources validate output using the provided schema
     * @param query - Query parameters for fetching data
     * @param outputSchema - Schema for validating output data
     * @param context - Context with environment
     */
    fetch?: <T>(query: unknown, outputSchema: z.ZodSchema<T>, context: BaseDataSourceContext) => Promise<T>;
    /**
     * Optional: Generate new content
     * Used by data sources that create content (e.g., AI-generated content, reports)
     */
    generate?: <T>(request: unknown, schema: z.ZodSchema<T>) => Promise<T>;
    /**
     * Optional: Transform content between formats
     * Used by data sources that convert content (e.g., markdown to HTML, data formatting)
     */
    transform?: <T>(content: unknown, format: string, schema: z.ZodSchema<T>) => Promise<T>;
}

declare const canonicalContentVisibilitySchema: z.ZodEnum<["public", "shared", "restricted"]>;
type ContentVisibility = z.infer<typeof canonicalContentVisibilitySchema>;
type RawContentVisibility = ContentVisibility | "private";

/** Canonical role of a stored conversation message. */
declare const messageRoleSchema: z.ZodEnum<["user", "assistant"]>;
type MessageRole = z.infer<typeof messageRoleSchema>;

/**
 * Options for entity mutation operations (create, update, upsert)
 */
interface EntityJobOptions {
    priority?: number;
    maxRetries?: number;
}

/**
 * Options for entity creation (extends EntityJobOptions with deduplication)
 */
interface CreateEntityOptions extends EntityJobOptions {
    deduplicateId?: boolean;
}
/**
 * Result of an entity mutation that triggers an embedding job.
 * When skipped is true, content was unchanged — no DB write, no event, no embedding job.
 */
interface EntityMutationResult {
    entityId: string;
    jobId: string;
    skipped: boolean;
}
/**
 * Input for adapter-validated direct creation from finalized markdown.
 */
interface CreateEntityFromMarkdownInput {
    entityType: string;
    id: string;
    markdown: string;
}
/**
 * Data for storing an embedding for an entity
 */
interface StoreEmbeddingData {
    entityId: string;
    entityType: string;
    embedding: Float32Array;
    contentHash: string;
}
/**
 * Base entity type - generic to support typed metadata
 * TMetadata defaults to Record<string, unknown> for backward compatibility
 */
interface BaseEntity<TMetadata = Record<string, unknown>> {
    id: string;
    entityType: string;
    content: string;
    created: string;
    updated: string;
    visibility: ContentVisibility;
    metadata: TMetadata;
    /** SHA256 hash of content for change detection */
    contentHash: string;
}
/**
 * Entity input type for creation - allows partial entities with optional system fields
 * contentHash is excluded because it's computed automatically by the entity service
 */
type EntityInput<T extends BaseEntity> = Omit<T, "id" | "created" | "updated" | "contentHash" | "visibility"> & {
    id?: string;
    created?: string;
    updated?: string;
    visibility?: RawContentVisibility;
};
/**
 * Search result type
 */
interface SearchResult<T extends BaseEntity = BaseEntity> {
    entity: T;
    score: number;
    excerpt: string;
}
/**
 * Normalized system_create input shape used by plugin create interceptors.
 */
interface CreateCoverImageInput {
    generate?: boolean | undefined;
    prompt?: string | undefined;
}
interface CreateFromAttachmentInput {
    kind: "entity-attachment";
    sourceEntityType: string;
    sourceEntityId: string;
    attachmentType: string;
}
interface CreateFromUploadInput {
    kind: "upload";
    id: string;
}
type CreateFromInput = CreateFromAttachmentInput | CreateFromUploadInput;
type CreateTransform = "extract-markdown";
interface CreateInput {
    entityType: string;
    prompt?: string;
    title?: string;
    content?: string;
    url?: string;
    from?: CreateFromInput;
    transform?: CreateTransform;
    replace?: boolean;
    targetEntityType?: string;
    targetEntityId?: string;
    coverImage?: boolean | CreateCoverImageInput;
}
/**
 * Minimal caller context forwarded to plugin create interceptors.
 */
interface CreateExecutionContext {
    interfaceType: string;
    userId: string;
    channelId?: string;
    channelName?: string;
}
/**
 * Result returned to system_create when a plugin fully handles creation.
 */
declare const createResultAttachmentSchema: z.ZodObject<{
    mediaType: z.ZodString;
    url: z.ZodString;
    downloadUrl: z.ZodOptional<z.ZodString>;
    previewUrl: z.ZodOptional<z.ZodString>;
    filename: z.ZodOptional<z.ZodString>;
    sizeBytes: z.ZodOptional<z.ZodNumber>;
    source: z.ZodOptional<z.ZodObject<{
        entityType: z.ZodOptional<z.ZodString>;
        entityId: z.ZodOptional<z.ZodString>;
        attachmentType: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        entityType?: string | undefined;
        entityId?: string | undefined;
        attachmentType?: string | undefined;
    }, {
        entityType?: string | undefined;
        entityId?: string | undefined;
        attachmentType?: string | undefined;
    }>>;
}, "strip", z.ZodTypeAny, {
    mediaType: string;
    url: string;
    downloadUrl?: string | undefined;
    previewUrl?: string | undefined;
    filename?: string | undefined;
    sizeBytes?: number | undefined;
    source?: {
        entityType?: string | undefined;
        entityId?: string | undefined;
        attachmentType?: string | undefined;
    } | undefined;
}, {
    mediaType: string;
    url: string;
    downloadUrl?: string | undefined;
    previewUrl?: string | undefined;
    filename?: string | undefined;
    sizeBytes?: number | undefined;
    source?: {
        entityType?: string | undefined;
        entityId?: string | undefined;
        attachmentType?: string | undefined;
    } | undefined;
}>;
type CreateResultAttachment = z.infer<typeof createResultAttachmentSchema>;
type CreateResult = {
    success: true;
    data: {
        entityId?: string;
        jobId?: string;
        status: string;
        attachment?: CreateResultAttachment;
    };
} | {
    success: false;
    error: string;
};
/**
 * Plugin create interceptors can either fully handle creation,
 * or continue with a rewritten normalized input.
 */
type CreateInterceptionResult = {
    kind: "handled";
    result: CreateResult;
} | {
    kind: "continue";
    input: CreateInput;
};
type CreateInterceptor = (input: CreateInput, executionContext: CreateExecutionContext) => Promise<CreateInterceptionResult>;
/**
 * Interface for entity adapter - handles conversion between entities and markdown
 * following the hybrid storage model
 *
 * @template TEntity - The full entity type
 * @template TMetadata - The metadata type (defaults to Record<string, unknown>)
 */
interface EntityAdapter<TEntity extends BaseEntity<TMetadata>, TMetadata = Record<string, unknown>> {
    entityType: string;
    schema: z.ZodType<TEntity, z.ZodTypeDef, unknown>;
    toMarkdown(entity: TEntity): string;
    fromMarkdown(markdown: string): Partial<TEntity>;
    extractMetadata(entity: TEntity): TMetadata;
    parseFrontMatter<TFrontmatter>(markdown: string, schema: z.ZodSchema<TFrontmatter>): TFrontmatter;
    generateFrontMatter(entity: TEntity): string;
    /** Optional: Zod schema for frontmatter fields. Used by CMS config generation. */
    frontmatterSchema?: z.ZodObject<z.ZodRawShape>;
    /** Optional: Declares this entity type is a singleton (one file, e.g., identity/identity.md). Used by CMS to generate files collection. */
    isSingleton?: boolean;
    /** Optional: Whether this entity has a free-form markdown body below frontmatter. Defaults to true. When false, CMS omits the body widget. */
    hasBody?: boolean;
    /** Returns a markdown body template with section headings for this entity type. Empty string for free-form entities. */
    getBodyTemplate(): string;
    /** Optional: Declares that this entity type supports cover images via coverImageId in frontmatter */
    supportsCoverImage?: boolean;
    /** Optional: Extract coverImageId from entity content/frontmatter */
    getCoverImageId?(entity: TEntity): string | undefined;
    /**
     * Optional: build the markdown content and metadata for a queued-generation stub.
     * When undefined, this entity type does not support prompt-based queued creation
     * via system_create; the tool will reject the call rather than silently degrade.
     * The returned metadata must satisfy this entity's metadata schema (with
     * status set to "generating"); central code only stamps id/timestamps/visibility.
     */
    buildStub?(input: {
        id: string;
        title: string;
    }): {
        content: string;
        metadata: TMetadata;
    };
}
/**
 * Sort field specification for multi-field sorting
 */
interface SortField {
    /** Field to sort by - "created", "updated", or a metadata field name */
    field: string;
    /** Sort direction */
    direction: "asc" | "desc";
    /** Sort NULL values before non-NULL values (default: false / SQLite default) */
    nullsFirst?: boolean;
}
/**
 * List entities options
 * Generic over metadata type for type-safe filtering
 */
interface ListOptions<TMetadata = Record<string, unknown>> {
    limit?: number;
    offset?: number;
    /** Multi-field sorting - supports system fields (created, updated) and metadata fields */
    sortFields?: SortField[];
    filter?: {
        metadata?: Partial<TMetadata>;
        visibilityScope?: ContentVisibility;
    };
    /** Filter to only entities with metadata.status = "published" */
    publishedOnly?: boolean;
}
/**
 * Search options
 */
interface SearchOptions {
    limit?: number;
    offset?: number;
    types?: string[];
    excludeTypes?: string[];
    sortBy?: "relevance" | "created" | "updated";
    sortDirection?: "asc" | "desc";
    /** Score multipliers per entity type - applied after initial search */
    weight?: Record<string, number>;
    visibilityScope?: ContentVisibility;
    /** Include queued/failed generation stubs in search results (default: false) */
    includeUngenerated?: boolean;
}
/**
 * Configuration for entity type registration
 */
interface EntityTypeConfig {
    /** Score multiplier for search results (default: 1.0) */
    weight?: number;
    /** Whether to generate embeddings for this entity type (default: true).
     *  Set to false for entity types with non-textual content (e.g., images). */
    embeddable?: boolean;
    /** Whether this entity type may be used as source material for derived projections (default: true).
     *  Set to false for projection outputs that would create feedback loops. */
    projectionSource?: boolean;
    /** Publish semantics for status-bearing entity types. Statuses listed here
     *  represent publication commitment/execution states and require the
     *  `publish` entity action when entered or modified. */
    publish?: {
        publishStatuses: string[];
    };
}
/**
 * Core entity service interface for read-only operations
 * Used by core plugins that need entity access but shouldn't modify entities
 */
interface GetEntityRequest {
    entityType: string;
    id: string;
    /**
     * Optional visibility scope. Undefined fails closed to "public" — callers
     * with elevated access must opt up explicitly.
     */
    visibilityScope?: ContentVisibility;
}
type GetEntityRawRequest = GetEntityRequest;
interface ListEntitiesRequest {
    entityType: string;
    options?: ListOptions | undefined;
}
interface CountEntitiesRequest {
    entityType: string;
    options?: Pick<ListOptions, "publishedOnly" | "filter"> | undefined;
}
interface CreateEntityRequest<T extends BaseEntity> {
    entity: EntityInput<T>;
    options?: CreateEntityOptions | undefined;
}
interface CreateEntityFromMarkdownRequest {
    input: CreateEntityFromMarkdownInput;
    options?: CreateEntityOptions | undefined;
}
interface UpdateEntityRequest<T extends BaseEntity> {
    entity: T;
    options?: EntityJobOptions | undefined;
}
interface DeleteEntityRequest {
    entityType: string;
    id: string;
}
interface UpsertEntityRequest<T extends BaseEntity> {
    entity: T;
    options?: EntityJobOptions | undefined;
}
interface EntitySearchRequest {
    query: string;
    options?: SearchOptions | undefined;
}
interface SearchWithDistancesRequest {
    query: string;
}
interface ICoreEntityService {
    getEntity<T extends BaseEntity>(request: GetEntityRequest): Promise<T | null>;
    /**
     * Get entity without content resolution (raw)
     * Used internally to avoid recursion when resolving image references
     */
    getEntityRaw<T extends BaseEntity>(request: GetEntityRawRequest): Promise<T | null>;
    listEntities<T extends BaseEntity>(request: ListEntitiesRequest): Promise<T[]>;
    search<T extends BaseEntity = BaseEntity>(request: EntitySearchRequest): Promise<SearchResult<T>[]>;
    getEntityTypes(): string[];
    hasEntityType(type: string): boolean;
    countEntities(request: CountEntitiesRequest): Promise<number>;
    /**
     * Group counts by entity type. Fails closed: undefined visibilityScope
     * filters to public-only counts so aggregate insights cannot reveal
     * non-public entity existence.
     */
    getEntityCounts(visibilityScope?: ContentVisibility): Promise<Array<{
        entityType: string;
        count: number;
    }>>;
    /** Get configuration for a specific entity type */
    getEntityTypeConfig(type: string): EntityTypeConfig;
    /** Get weight map for all registered entity types with non-default weights */
    getWeightMap(): Record<string, number>;
}
/**
 * Entity service interface for managing brain entities
 */
interface IEntitiesNamespace {
    /** Register a new entity type with schema and adapter */
    register<TEntity extends BaseEntity>(entityType: string, schema: z.ZodType<TEntity, z.ZodTypeDef, unknown>, adapter: EntityAdapter<TEntity>, config?: EntityTypeConfig): void;
    /**
     * Get the adapter for an entity type.
     *
     * Returns the structural `EntityAdapter<BaseEntity>` view — namespace
     * consumers don't narrow by entity type. For typed access tied to a
     * specific `TEntity`, use the underlying `EntityRegistry.getAdapter<T>`
     * directly (see `entity-serializer.ts`).
     */
    getAdapter(entityType: string): EntityAdapter<BaseEntity> | undefined;
    /** Extend an adapter's frontmatterSchema with additional fields */
    extendFrontmatterSchema(type: string, extension: z.ZodObject<z.ZodRawShape>): void;
    /** Get effective frontmatter schema (base + extensions) for an entity type */
    getEffectiveFrontmatterSchema(type: string): z.ZodObject<z.ZodRawShape> | undefined;
    /** Update an existing entity */
    update<TEntity extends BaseEntity>(entity: TEntity): Promise<{
        entityId: string;
        jobId: string;
    }>;
    /** Register a data source for dynamic content */
    registerDataSource(dataSource: DataSource): void;
    /** Register a create interceptor for this plugin's entity type */
    registerCreateInterceptor(entityType: string, interceptor: CreateInterceptor): void;
}
interface EntityService extends ICoreEntityService {
    createEntity<T extends BaseEntity>(request: CreateEntityRequest<T>): Promise<EntityMutationResult>;
    createEntityFromMarkdown(request: CreateEntityFromMarkdownRequest): Promise<EntityMutationResult>;
    updateEntity<T extends BaseEntity>(request: UpdateEntityRequest<T>): Promise<EntityMutationResult>;
    deleteEntity(request: DeleteEntityRequest): Promise<boolean>;
    upsertEntity<T extends BaseEntity>(request: UpsertEntityRequest<T>): Promise<EntityMutationResult & {
        created: boolean;
    }>;
    storeEmbedding(data: StoreEmbeddingData): Promise<void>;
    serializeEntity(entity: BaseEntity): string;
    deserializeEntity(markdown: string, entityType: string): Partial<BaseEntity>;
    countEmbeddings(): Promise<number>;
    searchWithDistances(request: SearchWithDistancesRequest): Promise<Array<{
        entityId: string;
        entityType: string;
        distance: number;
    }>>;
    initialize(): Promise<void>;
    getAsyncJobStatus(jobId: string): Promise<{
        status: "pending" | "processing" | "completed" | "failed";
        error?: string;
    } | null>;
}

/**
 * User permission level schema
 */
declare const UserPermissionLevelSchema: z.ZodEnum<["anchor", "trusted", "public"]>;
type UserPermissionLevel = z.infer<typeof UserPermissionLevelSchema>;
declare const EntityActionSchema: z.ZodEnum<["create", "update", "delete", "extract", "publish"]>;
type EntityAction = z.infer<typeof EntityActionSchema>;

/**
 * Renderer output formats supported by view templates.
 */
declare const OutputFormatSchema: z.ZodEnum<["web", "image", "pdf"]>;
type OutputFormat = z.infer<typeof OutputFormatSchema>;

declare const ChatContextSchema: z.ZodObject<{
    userPermissionLevel: z.ZodOptional<z.ZodEnum<["anchor", "trusted", "public"]>>;
    interfaceType: z.ZodOptional<z.ZodString>;
    channelId: z.ZodOptional<z.ZodString>;
    channelName: z.ZodOptional<z.ZodString>;
    actor: z.ZodOptional<z.ZodObject<{
        actorId: z.ZodString;
        canonicalId: z.ZodOptional<z.ZodString>;
        interfaceType: z.ZodString;
        role: z.ZodEnum<["user", "assistant"]>;
        displayName: z.ZodOptional<z.ZodString>;
        username: z.ZodOptional<z.ZodString>;
        isBot: z.ZodOptional<z.ZodBoolean>;
    }, "strip", z.ZodTypeAny, {
        interfaceType: string;
        actorId: string;
        role: "user" | "assistant";
        canonicalId?: string | undefined;
        displayName?: string | undefined;
        username?: string | undefined;
        isBot?: boolean | undefined;
    }, {
        interfaceType: string;
        actorId: string;
        role: "user" | "assistant";
        canonicalId?: string | undefined;
        displayName?: string | undefined;
        username?: string | undefined;
        isBot?: boolean | undefined;
    }>>;
    source: z.ZodOptional<z.ZodObject<{
        messageId: z.ZodOptional<z.ZodString>;
        channelId: z.ZodOptional<z.ZodString>;
        channelName: z.ZodOptional<z.ZodString>;
        threadId: z.ZodOptional<z.ZodString>;
        metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, "strip", z.ZodTypeAny, {
        channelId?: string | undefined;
        channelName?: string | undefined;
        messageId?: string | undefined;
        threadId?: string | undefined;
        metadata?: Record<string, unknown> | undefined;
    }, {
        channelId?: string | undefined;
        channelName?: string | undefined;
        messageId?: string | undefined;
        threadId?: string | undefined;
        metadata?: Record<string, unknown> | undefined;
    }>>;
    attachments: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
        kind: z.ZodLiteral<"text">;
        filename: z.ZodString;
        mediaType: z.ZodString;
        content: z.ZodString;
        sizeBytes: z.ZodOptional<z.ZodNumber>;
        source: z.ZodOptional<z.ZodObject<{
            kind: z.ZodString;
            id: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            kind: string;
            id: string;
        }, {
            kind: string;
            id: string;
        }>>;
    }, "strip", z.ZodTypeAny, {
        kind: "text";
        filename: string;
        mediaType: string;
        content: string;
        sizeBytes?: number | undefined;
        source?: {
            kind: string;
            id: string;
        } | undefined;
    }, {
        kind: "text";
        filename: string;
        mediaType: string;
        content: string;
        sizeBytes?: number | undefined;
        source?: {
            kind: string;
            id: string;
        } | undefined;
    }>, z.ZodObject<{
        kind: z.ZodLiteral<"file">;
        filename: z.ZodString;
        mediaType: z.ZodString;
        data: z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>;
        sizeBytes: z.ZodOptional<z.ZodNumber>;
        source: z.ZodOptional<z.ZodObject<{
            kind: z.ZodString;
            id: z.ZodString;
        }, "strip", z.ZodTypeAny, {
            kind: string;
            id: string;
        }, {
            kind: string;
            id: string;
        }>>;
    }, "strip", z.ZodTypeAny, {
        kind: "file";
        filename: string;
        mediaType: string;
        data: Uint8Array<ArrayBufferLike>;
        sizeBytes?: number | undefined;
        source?: {
            kind: string;
            id: string;
        } | undefined;
    }, {
        kind: "file";
        filename: string;
        mediaType: string;
        data: Uint8Array<ArrayBufferLike>;
        sizeBytes?: number | undefined;
        source?: {
            kind: string;
            id: string;
        } | undefined;
    }>]>, "many">>;
}, "strip", z.ZodTypeAny, {
    source?: {
        channelId?: string | undefined;
        channelName?: string | undefined;
        messageId?: string | undefined;
        threadId?: string | undefined;
        metadata?: Record<string, unknown> | undefined;
    } | undefined;
    userPermissionLevel?: "anchor" | "trusted" | "public" | undefined;
    interfaceType?: string | undefined;
    channelId?: string | undefined;
    channelName?: string | undefined;
    actor?: {
        interfaceType: string;
        actorId: string;
        role: "user" | "assistant";
        canonicalId?: string | undefined;
        displayName?: string | undefined;
        username?: string | undefined;
        isBot?: boolean | undefined;
    } | undefined;
    attachments?: ({
        kind: "text";
        filename: string;
        mediaType: string;
        content: string;
        sizeBytes?: number | undefined;
        source?: {
            kind: string;
            id: string;
        } | undefined;
    } | {
        kind: "file";
        filename: string;
        mediaType: string;
        data: Uint8Array<ArrayBufferLike>;
        sizeBytes?: number | undefined;
        source?: {
            kind: string;
            id: string;
        } | undefined;
    })[] | undefined;
}, {
    source?: {
        channelId?: string | undefined;
        channelName?: string | undefined;
        messageId?: string | undefined;
        threadId?: string | undefined;
        metadata?: Record<string, unknown> | undefined;
    } | undefined;
    userPermissionLevel?: "anchor" | "trusted" | "public" | undefined;
    interfaceType?: string | undefined;
    channelId?: string | undefined;
    channelName?: string | undefined;
    actor?: {
        interfaceType: string;
        actorId: string;
        role: "user" | "assistant";
        canonicalId?: string | undefined;
        displayName?: string | undefined;
        username?: string | undefined;
        isBot?: boolean | undefined;
    } | undefined;
    attachments?: ({
        kind: "text";
        filename: string;
        mediaType: string;
        content: string;
        sizeBytes?: number | undefined;
        source?: {
            kind: string;
            id: string;
        } | undefined;
    } | {
        kind: "file";
        filename: string;
        mediaType: string;
        data: Uint8Array<ArrayBufferLike>;
        sizeBytes?: number | undefined;
        source?: {
            kind: string;
            id: string;
        } | undefined;
    })[] | undefined;
}>;
type ChatContext = z.infer<typeof ChatContextSchema>;
declare const PendingConfirmationSchema: z.ZodObject<{
    id: z.ZodString;
    toolCallId: z.ZodOptional<z.ZodString>;
    toolName: z.ZodString;
    summary: z.ZodString;
    preview: z.ZodOptional<z.ZodString>;
    args: z.ZodUnknown;
}, "strip", z.ZodTypeAny, {
    id: string;
    toolName: string;
    summary: string;
    toolCallId?: string | undefined;
    preview?: string | undefined;
    args?: unknown;
}, {
    id: string;
    toolName: string;
    summary: string;
    toolCallId?: string | undefined;
    preview?: string | undefined;
    args?: unknown;
}>;
type PendingConfirmation = z.infer<typeof PendingConfirmationSchema>;
declare const ToolResultDataSchema: z.ZodObject<{
    toolName: z.ZodString;
    args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    jobId: z.ZodOptional<z.ZodString>;
    data: z.ZodOptional<z.ZodUnknown>;
}, "strip", z.ZodTypeAny, {
    toolName: string;
    data?: unknown;
    args?: Record<string, unknown> | undefined;
    jobId?: string | undefined;
}, {
    toolName: string;
    data?: unknown;
    args?: Record<string, unknown> | undefined;
    jobId?: string | undefined;
}>;
type ToolResultData = z.infer<typeof ToolResultDataSchema>;
declare const AgentResponseSchema: z.ZodObject<{
    text: z.ZodString;
    toolResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
        toolName: z.ZodString;
        args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        jobId: z.ZodOptional<z.ZodString>;
        data: z.ZodOptional<z.ZodUnknown>;
    }, "strip", z.ZodTypeAny, {
        toolName: string;
        data?: unknown;
        args?: Record<string, unknown> | undefined;
        jobId?: string | undefined;
    }, {
        toolName: string;
        data?: unknown;
        args?: Record<string, unknown> | undefined;
        jobId?: string | undefined;
    }>, "many">>;
    cards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
        kind: z.ZodLiteral<"tool-approval">;
        id: z.ZodString;
        toolCallId: z.ZodOptional<z.ZodString>;
        toolName: z.ZodString;
        input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        summary: z.ZodString;
        preview: z.ZodOptional<z.ZodString>;
        state: z.ZodEnum<["approval-requested", "approval-responded", "output-available", "output-denied", "output-error"]>;
        output: z.ZodOptional<z.ZodUnknown>;
        error: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        kind: "tool-approval";
        id: string;
        toolName: string;
        summary: string;
        state: "approval-requested" | "approval-responded" | "output-available" | "output-denied" | "output-error";
        toolCallId?: string | undefined;
        preview?: string | undefined;
        input?: Record<string, unknown> | undefined;
        output?: unknown;
        error?: string | undefined;
    }, {
        kind: "tool-approval";
        id: string;
        toolName: string;
        summary: string;
        state: "approval-requested" | "approval-responded" | "output-available" | "output-denied" | "output-error";
        toolCallId?: string | undefined;
        preview?: string | undefined;
        input?: Record<string, unknown> | undefined;
        output?: unknown;
        error?: string | undefined;
    }>, z.ZodObject<{
        kind: z.ZodLiteral<"attachment">;
        id: z.ZodString;
        jobId: z.ZodOptional<z.ZodString>;
        title: z.ZodString;
        description: z.ZodOptional<z.ZodString>;
        attachment: z.ZodObject<{
            mediaType: z.ZodString;
            url: z.ZodString;
            downloadUrl: z.ZodOptional<z.ZodString>;
            previewUrl: z.ZodOptional<z.ZodString>;
            filename: z.ZodOptional<z.ZodString>;
            sizeBytes: z.ZodOptional<z.ZodNumber>;
            source: z.ZodOptional<z.ZodObject<{
                entityType: z.ZodOptional<z.ZodString>;
                entityId: z.ZodOptional<z.ZodString>;
                attachmentType: z.ZodOptional<z.ZodString>;
            }, "strip", z.ZodTypeAny, {
                entityType?: string | undefined;
                entityId?: string | undefined;
                attachmentType?: string | undefined;
            }, {
                entityType?: string | undefined;
                entityId?: string | undefined;
                attachmentType?: string | undefined;
            }>>;
        }, "strip", z.ZodTypeAny, {
            mediaType: string;
            url: string;
            filename?: string | undefined;
            sizeBytes?: number | undefined;
            source?: {
                entityType?: string | undefined;
                entityId?: string | undefined;
                attachmentType?: string | undefined;
            } | undefined;
            downloadUrl?: string | undefined;
            previewUrl?: string | undefined;
        }, {
            mediaType: string;
            url: string;
            filename?: string | undefined;
            sizeBytes?: number | undefined;
            source?: {
                entityType?: string | undefined;
                entityId?: string | undefined;
                attachmentType?: string | undefined;
            } | undefined;
            downloadUrl?: string | undefined;
            previewUrl?: string | undefined;
        }>;
    }, "strip", z.ZodTypeAny, {
        kind: "attachment";
        id: string;
        attachment: {
            mediaType: string;
            url: string;
            filename?: string | undefined;
            sizeBytes?: number | undefined;
            source?: {
                entityType?: string | undefined;
                entityId?: string | undefined;
                attachmentType?: string | undefined;
            } | undefined;
            downloadUrl?: string | undefined;
            previewUrl?: string | undefined;
        };
        title: string;
        jobId?: string | undefined;
        description?: string | undefined;
    }, {
        kind: "attachment";
        id: string;
        attachment: {
            mediaType: string;
            url: string;
            filename?: string | undefined;
            sizeBytes?: number | undefined;
            source?: {
                entityType?: string | undefined;
                entityId?: string | undefined;
                attachmentType?: string | undefined;
            } | undefined;
            downloadUrl?: string | undefined;
            previewUrl?: string | undefined;
        };
        title: string;
        jobId?: string | undefined;
        description?: string | undefined;
    }>, z.ZodObject<{
        kind: z.ZodLiteral<"sources">;
        id: z.ZodString;
        title: z.ZodOptional<z.ZodString>;
        sources: z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            title: z.ZodOptional<z.ZodString>;
            source: z.ZodString;
            url: z.ZodOptional<z.ZodString>;
            entityType: z.ZodOptional<z.ZodString>;
            entityId: z.ZodOptional<z.ZodString>;
            excerpt: z.ZodOptional<z.ZodString>;
            provenance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        }, "strip", z.ZodTypeAny, {
            id: string;
            source: string;
            entityType?: string | undefined;
            entityId?: string | undefined;
            url?: string | undefined;
            title?: string | undefined;
            excerpt?: string | undefined;
            provenance?: Record<string, unknown> | undefined;
        }, {
            id: string;
            source: string;
            entityType?: string | undefined;
            entityId?: string | undefined;
            url?: string | undefined;
            title?: string | undefined;
            excerpt?: string | undefined;
            provenance?: Record<string, unknown> | undefined;
        }>, "many">;
    }, "strip", z.ZodTypeAny, {
        kind: "sources";
        id: string;
        sources: {
            id: string;
            source: string;
            entityType?: string | undefined;
            entityId?: string | undefined;
            url?: string | undefined;
            title?: string | undefined;
            excerpt?: string | undefined;
            provenance?: Record<string, unknown> | undefined;
        }[];
        title?: string | undefined;
    }, {
        kind: "sources";
        id: string;
        sources: {
            id: string;
            source: string;
            entityType?: string | undefined;
            entityId?: string | undefined;
            url?: string | undefined;
            title?: string | undefined;
            excerpt?: string | undefined;
            provenance?: Record<string, unknown> | undefined;
        }[];
        title?: string | undefined;
    }>, z.ZodObject<{
        kind: z.ZodLiteral<"actions">;
        id: z.ZodString;
        title: z.ZodOptional<z.ZodString>;
        defaultOpen: z.ZodOptional<z.ZodBoolean>;
        actions: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
            type: z.ZodLiteral<"prompt">;
            id: z.ZodString;
            label: z.ZodString;
            prompt: z.ZodString;
            description: z.ZodOptional<z.ZodString>;
        }, "strip", z.ZodTypeAny, {
            id: string;
            type: "prompt";
            prompt: string;
            label: string;
            description?: string | undefined;
        }, {
            id: string;
            type: "prompt";
            prompt: string;
            label: string;
            description?: string | undefined;
        }>, z.ZodObject<{
            type: z.ZodLiteral<"event">;
            id: z.ZodString;
            label: z.ZodString;
            event: z.ZodString;
            description: z.ZodOptional<z.ZodString>;
        }, "strip", z.ZodTypeAny, {
            id: string;
            type: "event";
            label: string;
            event: string;
            description?: string | undefined;
        }, {
            id: string;
            type: "event";
            label: string;
            event: string;
            description?: string | undefined;
        }>]>, "many">;
    }, "strip", z.ZodTypeAny, {
        kind: "actions";
        id: string;
        actions: ({
            id: string;
            type: "prompt";
            prompt: string;
            label: string;
            description?: string | undefined;
        } | {
            id: string;
            type: "event";
            label: string;
            event: string;
            description?: string | undefined;
        })[];
        title?: string | undefined;
        defaultOpen?: boolean | undefined;
    }, {
        kind: "actions";
        id: string;
        actions: ({
            id: string;
            type: "prompt";
            prompt: string;
            label: string;
            description?: string | undefined;
        } | {
            id: string;
            type: "event";
            label: string;
            event: string;
            description?: string | undefined;
        })[];
        title?: string | undefined;
        defaultOpen?: boolean | undefined;
    }>]>, "many">>;
    pendingConfirmations: z.ZodOptional<z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        toolCallId: z.ZodOptional<z.ZodString>;
        toolName: z.ZodString;
        summary: z.ZodString;
        preview: z.ZodOptional<z.ZodString>;
        args: z.ZodUnknown;
    }, "strip", z.ZodTypeAny, {
        id: string;
        toolName: string;
        summary: string;
        toolCallId?: string | undefined;
        preview?: string | undefined;
        args?: unknown;
    }, {
        id: string;
        toolName: string;
        summary: string;
        toolCallId?: string | undefined;
        preview?: string | undefined;
        args?: unknown;
    }>, "many">>;
    usage: z.ZodObject<{
        promptTokens: z.ZodNumber;
        completionTokens: z.ZodNumber;
        totalTokens: z.ZodNumber;
    }, "strip", z.ZodTypeAny, {
        promptTokens: number;
        completionTokens: number;
        totalTokens: number;
    }, {
        promptTokens: number;
        completionTokens: number;
        totalTokens: number;
    }>;
}, "strip", z.ZodTypeAny, {
    text: string;
    usage: {
        promptTokens: number;
        completionTokens: number;
        totalTokens: number;
    };
    toolResults?: {
        toolName: string;
        data?: unknown;
        args?: Record<string, unknown> | undefined;
        jobId?: string | undefined;
    }[] | undefined;
    cards?: ({
        kind: "tool-approval";
        id: string;
        toolName: string;
        summary: string;
        state: "approval-requested" | "approval-responded" | "output-available" | "output-denied" | "output-error";
        toolCallId?: string | undefined;
        preview?: string | undefined;
        input?: Record<string, unknown> | undefined;
        output?: unknown;
        error?: string | undefined;
    } | {
        kind: "attachment";
        id: string;
        attachment: {
            mediaType: string;
            url: string;
            filename?: string | undefined;
            sizeBytes?: number | undefined;
            source?: {
                entityType?: string | undefined;
                entityId?: string | undefined;
                attachmentType?: string | undefined;
            } | undefined;
            downloadUrl?: string | undefined;
            previewUrl?: string | undefined;
        };
        title: string;
        jobId?: string | undefined;
        description?: string | undefined;
    } | {
        kind: "sources";
        id: string;
        sources: {
            id: string;
            source: string;
            entityType?: string | undefined;
            entityId?: string | undefined;
            url?: string | undefined;
            title?: string | undefined;
            excerpt?: string | undefined;
            provenance?: Record<string, unknown> | undefined;
        }[];
        title?: string | undefined;
    } | {
        kind: "actions";
        id: string;
        actions: ({
            id: string;
            type: "prompt";
            prompt: string;
            label: string;
            description?: string | undefined;
        } | {
            id: string;
            type: "event";
            label: string;
            event: string;
            description?: string | undefined;
        })[];
        title?: string | undefined;
        defaultOpen?: boolean | undefined;
    })[] | undefined;
    pendingConfirmations?: {
        id: string;
        toolName: string;
        summary: string;
        toolCallId?: string | undefined;
        preview?: string | undefined;
        args?: unknown;
    }[] | undefined;
}, {
    text: string;
    usage: {
        promptTokens: number;
        completionTokens: number;
        totalTokens: number;
    };
    toolResults?: {
        toolName: string;
        data?: unknown;
        args?: Record<string, unknown> | undefined;
        jobId?: string | undefined;
    }[] | undefined;
    cards?: ({
        kind: "tool-approval";
        id: string;
        toolName: string;
        summary: string;
        state: "approval-requested" | "approval-responded" | "output-available" | "output-denied" | "output-error";
        toolCallId?: string | undefined;
        preview?: string | undefined;
        input?: Record<string, unknown> | undefined;
        output?: unknown;
        error?: string | undefined;
    } | {
        kind: "attachment";
        id: string;
        attachment: {
            mediaType: string;
            url: string;
            filename?: string | undefined;
            sizeBytes?: number | undefined;
            source?: {
                entityType?: string | undefined;
                entityId?: string | undefined;
                attachmentType?: string | undefined;
            } | undefined;
            downloadUrl?: string | undefined;
            previewUrl?: string | undefined;
        };
        title: string;
        jobId?: string | undefined;
        description?: string | undefined;
    } | {
        kind: "sources";
        id: string;
        sources: {
            id: string;
            source: string;
            entityType?: string | undefined;
            entityId?: string | undefined;
            url?: string | undefined;
            title?: string | undefined;
            excerpt?: string | undefined;
            provenance?: Record<string, unknown> | undefined;
        }[];
        title?: string | undefined;
    } | {
        kind: "actions";
        id: string;
        actions: ({
            id: string;
            type: "prompt";
            prompt: string;
            label: string;
            description?: string | undefined;
        } | {
            id: string;
            type: "event";
            label: string;
            event: string;
            description?: string | undefined;
        })[];
        title?: string | undefined;
        defaultOpen?: boolean | undefined;
    })[] | undefined;
    pendingConfirmations?: {
        id: string;
        toolName: string;
        summary: string;
        toolCallId?: string | undefined;
        preview?: string | undefined;
        args?: unknown;
    }[] | undefined;
}>;
type AgentResponse = z.infer<typeof AgentResponseSchema>;
interface AgentNamespace {
    chat(message: string, conversationId: string, context?: ChatContext): Promise<AgentResponse>;
    confirmPendingAction(conversationId: string, confirmed: boolean, approvalId: string): Promise<AgentResponse>;
    invalidate(): void;
}

declare const AppInfoSchema: z.ZodObject<{
    model: z.ZodString;
    version: z.ZodString;
    uptime: z.ZodNumber;
    entities: z.ZodNumber;
    entityCounts: z.ZodArray<z.ZodObject<{
        entityType: z.ZodString;
        count: z.ZodNumber;
    }, "strip", z.ZodTypeAny, {
        entityType: string;
        count: number;
    }, {
        entityType: string;
        count: number;
    }>, "many">;
    embeddings: z.ZodNumber;
    ai: z.ZodObject<{
        model: z.ZodString;
        embeddingModel: z.ZodString;
    }, "strip", z.ZodTypeAny, {
        model: string;
        embeddingModel: string;
    }, {
        model: string;
        embeddingModel: string;
    }>;
    daemons: z.ZodArray<z.ZodObject<{
        name: z.ZodString;
        pluginId: z.ZodString;
        status: z.ZodString;
        health: z.ZodOptional<z.ZodObject<{
            status: z.ZodEnum<["healthy", "warning", "error", "unknown"]>;
            message: z.ZodOptional<z.ZodString>;
            lastCheck: z.ZodOptional<z.ZodString>;
            details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        }, "strip", z.ZodTypeAny, {
            status: "unknown" | "error" | "healthy" | "warning";
            message?: string | undefined;
            lastCheck?: string | undefined;
            details?: Record<string, unknown> | undefined;
        }, {
            status: "unknown" | "error" | "healthy" | "warning";
            message?: string | undefined;
            lastCheck?: string | undefined;
            details?: Record<string, unknown> | undefined;
        }>>;
    }, "strip", z.ZodTypeAny, {
        status: string;
        name: string;
        pluginId: string;
        health?: {
            status: "unknown" | "error" | "healthy" | "warning";
            message?: string | undefined;
            lastCheck?: string | undefined;
            details?: Record<string, unknown> | undefined;
        } | undefined;
    }, {
        status: string;
        name: string;
        pluginId: string;
        health?: {
            status: "unknown" | "error" | "healthy" | "warning";
            message?: string | undefined;
            lastCheck?: string | undefined;
            details?: Record<string, unknown> | undefined;
        } | undefined;
    }>, "many">;
    endpoints: z.ZodArray<z.ZodObject<{
        label: z.ZodString;
        url: z.ZodString;
        pluginId: z.ZodString;
        priority: z.ZodDefault<z.ZodNumber>;
        visibility: z.ZodDefault<z.ZodEnum<["anchor", "trusted", "public"]>>;
    }, "strip", z.ZodTypeAny, {
        url: string;
        label: string;
        pluginId: string;
        priority: number;
        visibility: "anchor" | "trusted" | "public";
    }, {
        url: string;
        label: string;
        pluginId: string;
        priority?: number | undefined;
        visibility?: "anchor" | "trusted" | "public" | undefined;
    }>, "many">;
    interactions: z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        label: z.ZodString;
        description: z.ZodOptional<z.ZodString>;
        href: z.ZodString;
        kind: z.ZodEnum<["human", "agent", "admin", "protocol"]>;
        pluginId: z.ZodString;
        priority: z.ZodDefault<z.ZodNumber>;
        visibility: z.ZodDefault<z.ZodEnum<["anchor", "trusted", "public"]>>;
        status: z.ZodDefault<z.ZodEnum<["available", "coming-soon", "disabled"]>>;
    }, "strip", z.ZodTypeAny, {
        kind: "human" | "agent" | "admin" | "protocol";
        id: string;
        status: "available" | "coming-soon" | "disabled";
        label: string;
        pluginId: string;
        priority: number;
        visibility: "anchor" | "trusted" | "public";
        href: string;
        description?: string | undefined;
    }, {
        kind: "human" | "agent" | "admin" | "protocol";
        id: string;
        label: string;
        pluginId: string;
        href: string;
        status?: "available" | "coming-soon" | "disabled" | undefined;
        description?: string | undefined;
        priority?: number | undefined;
        visibility?: "anchor" | "trusted" | "public" | undefined;
    }>, "many">;
}, "strip", z.ZodTypeAny, {
    model: string;
    version: string;
    uptime: number;
    entities: number;
    entityCounts: {
        entityType: string;
        count: number;
    }[];
    embeddings: number;
    ai: {
        model: string;
        embeddingModel: string;
    };
    daemons: {
        status: string;
        name: string;
        pluginId: string;
        health?: {
            status: "unknown" | "error" | "healthy" | "warning";
            message?: string | undefined;
            lastCheck?: string | undefined;
            details?: Record<string, unknown> | undefined;
        } | undefined;
    }[];
    endpoints: {
        url: string;
        label: string;
        pluginId: string;
        priority: number;
        visibility: "anchor" | "trusted" | "public";
    }[];
    interactions: {
        kind: "human" | "agent" | "admin" | "protocol";
        id: string;
        status: "available" | "coming-soon" | "disabled";
        label: string;
        pluginId: string;
        priority: number;
        visibility: "anchor" | "trusted" | "public";
        href: string;
        description?: string | undefined;
    }[];
}, {
    model: string;
    version: string;
    uptime: number;
    entities: number;
    entityCounts: {
        entityType: string;
        count: number;
    }[];
    embeddings: number;
    ai: {
        model: string;
        embeddingModel: string;
    };
    daemons: {
        status: string;
        name: string;
        pluginId: string;
        health?: {
            status: "unknown" | "error" | "healthy" | "warning";
            message?: string | undefined;
            lastCheck?: string | undefined;
            details?: Record<string, unknown> | undefined;
        } | undefined;
    }[];
    endpoints: {
        url: string;
        label: string;
        pluginId: string;
        priority?: number | undefined;
        visibility?: "anchor" | "trusted" | "public" | undefined;
    }[];
    interactions: {
        kind: "human" | "agent" | "admin" | "protocol";
        id: string;
        label: string;
        pluginId: string;
        href: string;
        status?: "available" | "coming-soon" | "disabled" | undefined;
        description?: string | undefined;
        priority?: number | undefined;
        visibility?: "anchor" | "trusted" | "public" | undefined;
    }[];
}>;
type AppInfo = z.infer<typeof AppInfoSchema>;

declare const ConversationSchema: z.ZodObject<{
    id: z.ZodString;
    sessionId: z.ZodString;
    interfaceType: z.ZodString;
    channelId: z.ZodString;
    channelName: z.ZodOptional<z.ZodString>;
    startedAt: z.ZodString;
    lastActiveAt: z.ZodString;
    createdAt: z.ZodString;
    updatedAt: z.ZodString;
    metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
}, "strip", z.ZodTypeAny, {
    id: string;
    interfaceType: string;
    channelId: string;
    metadata: Record<string, unknown>;
    sessionId: string;
    startedAt: string;
    lastActiveAt: string;
    createdAt: string;
    updatedAt: string;
    channelName?: string | undefined;
}, {
    id: string;
    interfaceType: string;
    channelId: string;
    metadata: Record<string, unknown>;
    sessionId: string;
    startedAt: string;
    lastActiveAt: string;
    createdAt: string;
    updatedAt: string;
    channelName?: string | undefined;
}>;
type Conversation = z.infer<typeof ConversationSchema>;
declare const MessageSchema: z.ZodObject<{
    id: z.ZodString;
    conversationId: z.ZodString;
    role: z.ZodEnum<["user", "assistant"]>;
    content: z.ZodString;
    timestamp: z.ZodString;
    metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
}, "strip", z.ZodTypeAny, {
    id: string;
    content: string;
    role: "user" | "assistant";
    metadata: Record<string, unknown>;
    conversationId: string;
    timestamp: string;
}, {
    id: string;
    content: string;
    role: "user" | "assistant";
    metadata: Record<string, unknown>;
    conversationId: string;
    timestamp: string;
}>;
type Message = z.infer<typeof MessageSchema>;

declare const BrainCharacterSchema: z.ZodObject<{
    name: z.ZodString;
    role: z.ZodString;
    purpose: z.ZodString;
    values: z.ZodArray<z.ZodString, "many">;
}, "strip", z.ZodTypeAny, {
    values: string[];
    role: string;
    name: string;
    purpose: string;
}, {
    values: string[];
    role: string;
    name: string;
    purpose: string;
}>;
type BrainCharacter = z.infer<typeof BrainCharacterSchema>;
declare const AnchorProfileSchema: z.ZodObject<{
    name: z.ZodString;
    kind: z.ZodEnum<["professional", "team", "collective"]>;
    organization: z.ZodOptional<z.ZodString>;
    description: z.ZodOptional<z.ZodString>;
    avatar: z.ZodOptional<z.ZodString>;
    website: z.ZodOptional<z.ZodString>;
    email: z.ZodOptional<z.ZodString>;
    socialLinks: z.ZodOptional<z.ZodArray<z.ZodObject<{
        platform: z.ZodEnum<["github", "instagram", "linkedin", "email", "website"]>;
        url: z.ZodString;
        label: z.ZodOptional<z.ZodString>;
    }, "strip", z.ZodTypeAny, {
        url: string;
        platform: "website" | "email" | "github" | "instagram" | "linkedin";
        label?: string | undefined;
    }, {
        url: string;
        platform: "website" | "email" | "github" | "instagram" | "linkedin";
        label?: string | undefined;
    }>, "many">>;
}, "strip", z.ZodTypeAny, {
    kind: "professional" | "team" | "collective";
    name: string;
    description?: string | undefined;
    organization?: string | undefined;
    avatar?: string | undefined;
    website?: string | undefined;
    email?: string | undefined;
    socialLinks?: {
        url: string;
        platform: "website" | "email" | "github" | "instagram" | "linkedin";
        label?: string | undefined;
    }[] | undefined;
}, {
    kind: "professional" | "team" | "collective";
    name: string;
    description?: string | undefined;
    organization?: string | undefined;
    avatar?: string | undefined;
    website?: string | undefined;
    email?: string | undefined;
    socialLinks?: {
        url: string;
        platform: "website" | "email" | "github" | "instagram" | "linkedin";
        label?: string | undefined;
    }[] | undefined;
}>;
type AnchorProfile = z.infer<typeof AnchorProfileSchema>;

/**
 * Best-effort extension metadata carried across public DTO boundaries.
 *
 * Individual keys are not stable public API. When a metadata value becomes a
 * documented contract, hoist it to a typed top-level field on the owning DTO
 * schema and keep this bag only as optional extension data.
 */
declare const ExtensionMetadataSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
type ExtensionMetadata = z.infer<typeof ExtensionMetadataSchema>;

declare const MessageResponseSchema: z.ZodUnion<[z.ZodObject<{
    success: z.ZodBoolean;
    data: z.ZodOptional<z.ZodUnknown>;
    error: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
    success: boolean;
    data?: unknown;
    error?: string | undefined;
}, {
    success: boolean;
    data?: unknown;
    error?: string | undefined;
}>, z.ZodObject<{
    noop: z.ZodLiteral<true>;
}, "strip", z.ZodTypeAny, {
    noop: true;
}, {
    noop: true;
}>]>;
type MessageResponse<T = unknown> = ({
    success: boolean;
    error?: string | undefined;
} & {
    data?: T | undefined;
}) | {
    noop: true;
};
declare const BaseMessageSchema: z.ZodObject<{
    id: z.ZodString;
    timestamp: z.ZodString;
    type: z.ZodString;
    source: z.ZodString;
    target: z.ZodOptional<z.ZodString>;
    metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, "strip", z.ZodTypeAny, {
    id: string;
    type: string;
    source: string;
    timestamp: string;
    metadata?: Record<string, unknown> | undefined;
    target?: string | undefined;
}, {
    id: string;
    type: string;
    source: string;
    timestamp: string;
    metadata?: Record<string, unknown> | undefined;
    target?: string | undefined;
}>;
type BaseMessage = z.infer<typeof BaseMessageSchema>;
type MessageWithPayload<T = unknown> = BaseMessage & {
    payload: T;
};
interface MessageSendOptions {
    target?: string;
    metadata?: z.infer<typeof ExtensionMetadataSchema>;
    broadcast?: boolean;
}
interface MessageSendRequest<T = unknown> extends MessageSendOptions {
    type: string;
    payload: T;
}
type MessageSender<T = unknown, R = unknown> = (request: MessageSendRequest<T>) => Promise<MessageResponse<R>>;
interface MessageContext {
    userId?: string;
    channelId?: string;
    messageId?: string;
    timestamp?: string;
    interfaceType?: string;
    userPermissionLevel?: UserPermissionLevel;
    threadId?: string;
}

type PluginConfig = Record<string, unknown>;
type PluginConfigInput<T extends z.ZodTypeAny> = z.input<T>;
interface Plugin {
    readonly id: string;
    readonly version: string;
    readonly type: "core" | "entity" | "service" | "interface";
    readonly packageName: string;
    readonly description?: string;
    readonly dependencies?: string[];
    ready?(): Promise<void>;
    shutdown?(): Promise<void>;
    requiresDaemonStartup?(): boolean;
}
type PluginFactory = (config: PluginConfig) => Plugin | Plugin[];
interface Logger {
    debug(message: string, data?: unknown): void;
    info(message: string, data?: unknown): void;
    warn(message: string, data?: unknown): void;
    error(message: string, data?: unknown): void;
    child(context: string): Logger;
}
interface ToolContext {
    progressToken?: string | number;
    sendProgress?: (notification: {
        progress?: number;
        total?: number;
        message?: string;
    }) => Promise<void>;
    interfaceType?: string;
    userId?: string;
    channelId?: string;
    channelName?: string;
    userPermissionLevel?: UserPermissionLevel;
}
interface ToolResponse<T = unknown> {
    success: boolean;
    data?: T;
    error?: string;
}
type ToolVisibility = UserPermissionLevel;
interface ToolConfirmation {
    required: boolean;
    message?: string;
}
interface Tool<TArgs = unknown, TResult = unknown> {
    name: string;
    description: string;
    inputSchema: z.ZodRawShape;
    handler: (args: TArgs, context: ToolContext) => Promise<TResult> | TResult;
    visibility?: ToolVisibility;
    confirmation?: ToolConfirmation;
}
interface Resource<TResult = unknown> {
    uri: string;
    name: string;
    description?: string;
    mimeType?: string;
    handler: () => Promise<TResult> | TResult;
}
interface ResourceTemplate<K extends string = string> {
    uriTemplate: K;
    name: string;
    description?: string;
    mimeType?: string;
}
interface Prompt {
    name: string;
    description?: string;
    arguments?: Array<{
        name: string;
        description?: string;
        required?: boolean;
    }>;
}
declare function createTool<TArgs = unknown, TResult = unknown>(tool: Tool<TArgs, TResult>): Tool<TArgs, TResult>;
declare function createResource<TResult = unknown>(resource: Resource<TResult>): Resource<TResult>;
declare function toolSuccess<T = unknown>(data?: T): ToolResponse<T>;
declare function toolError(error: string): ToolResponse<never>;
interface BaseJobTrackingInfo {
    rootJobId: string;
}
interface MessageJobTrackingInfo extends BaseJobTrackingInfo {
    messageId?: string;
    channelId?: string;
}
type JobProgressStatus = "pending" | "processing" | "completed" | "failed";
interface JobProgressContext {
    rootJobId: string;
    operationType: "file_operations" | "content_operations" | "data_processing" | "batch_processing";
    pluginId?: string | undefined;
    progressToken?: string | number | undefined;
    operationTarget?: string | undefined;
    interfaceType?: string | undefined;
    channelId?: string | undefined;
}
interface JobProgressEvent {
    id: string;
    type: "job" | "batch";
    status: JobProgressStatus;
    message?: string | undefined;
    progress?: {
        current: number;
        total: number;
        percentage: number;
    } | undefined;
    aggregationKey?: string | undefined;
    batchDetails?: {
        totalOperations: number;
        completedOperations: number;
        failedOperations: number;
        currentOperation?: string | undefined;
        errors?: string[] | undefined;
    } | undefined;
    jobDetails?: {
        jobType: string;
        priority: number;
        retryCount: number;
    } | undefined;
    metadata: JobProgressContext;
}
declare const urlCaptureConfigSchema: z.ZodObject<{
    captureUrls: z.ZodDefault<z.ZodBoolean>;
    blockedUrlDomains: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
    captureUrls: boolean;
    blockedUrlDomains: string[];
}, {
    captureUrls?: boolean | undefined;
    blockedUrlDomains?: string[] | undefined;
}>;
interface Channel<TPayload, TResponse = unknown> {
    readonly name: string;
    readonly schema: z.ZodType<TPayload>;
    readonly _response?: TResponse;
}
declare function defineChannel<TPayload, TResponse = unknown>(name: string, schema: z.ZodType<TPayload>): Channel<TPayload, TResponse>;
type PublicEntityServiceMethods = "getEntity" | "listEntities" | "search" | "getEntityTypes" | "hasEntityType" | "countEntities" | "getEntityCounts" | "getEntityTypeConfig";
type IEntityService = Pick<ICoreEntityService, PublicEntityServiceMethods>;

interface IIdentityNamespace {
    get: () => BrainCharacter;
    getProfile: () => AnchorProfile;
    getAppInfo: () => Promise<AppInfo>;
}
interface IConversationsNamespace {
    get(conversationId: string): Promise<Conversation | null>;
    search(query: string): Promise<Conversation[]>;
    list(options?: {
        limit?: number;
        updatedAfter?: string;
        interfaceType?: string;
        sessionId?: string;
        channelId?: string;
    }): Promise<Conversation[]>;
    getMessages(conversationId: string, options?: {
        limit?: number;
        range?: {
            start: number;
            end: number;
        };
    }): Promise<Message[]>;
}
interface IMessagingNamespace {
    send: MessageSender;
    subscribe<T = unknown, R = unknown>(channel: string | Channel<T, R>, handler: (message: MessageWithPayload<T>) => Promise<MessageResponse<R>>): () => void;
}
type EvalHandler<TInput = unknown, TOutput = unknown> = (input: TInput) => Promise<TOutput>;
type InsightHandler = (entityService: IEntityService, visibilityScope: ContentVisibility) => Promise<Record<string, unknown>>;
interface IEvalNamespace {
    registerHandler(handlerId: string, handler: EvalHandler): void;
}
interface IInsightsNamespace {
    register(type: string, handler: InsightHandler): void;
}
interface IPermissionsNamespace {
    assertEntityActionAllowed(entityType: string, action: EntityAction, context: {
        userPermissionLevel?: UserPermissionLevel | undefined;
    }): void;
}
interface RuntimeUploadRecord {
    id: string;
    ref: {
        kind: string;
        id: string;
    };
    filename: string;
    mediaType: string;
    sizeBytes: number;
    createdAt: string;
}
interface RuntimeUploadResponseBody extends RuntimeUploadRecord {
    url: string;
    downloadUrl: string;
}
interface ResolvedRuntimeUpload {
    record: RuntimeUploadRecord;
    content: Buffer;
}
interface SaveRuntimeUploadInput {
    filename: string;
    mediaType: string;
    content: Buffer;
}
interface RuntimeUploadScopeOptions {
    namespace: string;
    refKind: string;
    routePath: string;
    retentionMs?: number | undefined;
    maxCount?: number | undefined;
}
interface RuntimeUploadStore {
    save(input: SaveRuntimeUploadInput): Promise<RuntimeUploadRecord>;
    read(uploadId: string): Promise<ResolvedRuntimeUpload>;
    readRecord(uploadId: string): Promise<RuntimeUploadRecord>;
    toResponseBody(record: RuntimeUploadRecord): RuntimeUploadResponseBody;
    prune(): Promise<void>;
    getUploadDir(uploadId: string): string;
}
interface IRuntimeUploadsNamespace {
    scoped(options: RuntimeUploadScopeOptions): RuntimeUploadStore;
}
interface BasePluginContext {
    readonly pluginId: string;
    readonly logger: Logger;
    readonly dataDir: string;
    readonly domain: string | undefined;
    readonly siteUrl: string | undefined;
    readonly localSiteUrl: string | undefined;
    readonly previewUrl: string | undefined;
    readonly preferLocalUrls: boolean;
    readonly appInfo: () => Promise<AppInfo>;
    readonly entityService: IEntityService;
    readonly identity: IIdentityNamespace;
    readonly messaging: IMessagingNamespace;
    readonly conversations: IConversationsNamespace;
    readonly eval: IEvalNamespace;
    readonly insights: IInsightsNamespace;
    readonly permissions: IPermissionsNamespace;
    readonly uploads: IRuntimeUploadsNamespace;
}
interface IPromptsNamespace {
    resolve(target: string, fallback: string): Promise<string>;
}
interface IServiceTemplatesNamespace {
    register(templates: unknown): void;
}
interface IViewsNamespace {
    get(name: string): unknown | undefined;
    list(): unknown[];
    hasRenderer(templateName: string, format?: OutputFormat): boolean;
    getRenderer(templateName: string, format?: OutputFormat): unknown | undefined;
    validate(templateName: string, content: unknown): boolean;
}
interface ServicePluginContext extends BasePluginContext {
    readonly entities: IEntitiesNamespace;
    readonly templates: IServiceTemplatesNamespace;
    readonly views: IViewsNamespace;
    readonly prompts: IPromptsNamespace;
    registerInstructions(instructions: string): void;
}
interface EntityPluginContext extends BasePluginContext {
    readonly entities: IEntitiesNamespace;
    readonly prompts: IPromptsNamespace;
}
interface InterfacePluginContext extends BasePluginContext {
    readonly agent: AgentNamespace;
}

declare abstract class EntityPlugin<TEntity extends BaseEntity = BaseEntity, TConfig = unknown> implements Plugin {
    readonly type: "entity";
    readonly id: string;
    readonly version: string;
    readonly packageName: string;
    readonly description?: string;
    abstract readonly entityType: string;
    abstract readonly schema: z.ZodSchema<TEntity>;
    abstract readonly adapter: EntityAdapter<TEntity>;
    private readonly delegate;
    protected constructor(id: string, packageJson: {
        name: string;
        version: string;
        description?: string;
    }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
    protected onRegister(_context: EntityPluginContext): Promise<void>;
    protected onReady(_context: EntityPluginContext): Promise<void>;
    protected onShutdown(): Promise<void>;
    protected getInstructions(): Promise<string | undefined>;
    protected getEntityTypeConfig(): EntityTypeConfig | undefined;
    protected getDataSources(): DataSource[];
    protected interceptCreate(input: CreateInput, _executionContext: CreateExecutionContext, _context: EntityPluginContext): Promise<CreateInterceptionResult>;
    ready(): Promise<void>;
    shutdown(): Promise<void>;
}

declare const WebRouteMethods: readonly ["GET", "POST", "PUT", "DELETE", "OPTIONS"];
type WebRouteMethod = (typeof WebRouteMethods)[number];
type WebRouteHandler = (request: Request) => Response | Promise<Response>;
interface WebRouteDefinition {
    /** Absolute mounted path (e.g. "/cms" or "/cms-config") */
    path: string;
    /** HTTP method */
    method?: WebRouteMethod;
    /** Allow unauthenticated access */
    public?: boolean;
    /** Request handler */
    handler: WebRouteHandler;
}

declare abstract class InterfacePlugin<TConfig = unknown, TTrackingInfo extends BaseJobTrackingInfo = BaseJobTrackingInfo> implements Plugin {
    readonly type: "interface";
    readonly id: string;
    readonly version: string;
    readonly packageName: string;
    readonly description?: string;
    private readonly delegate;
    protected constructor(id: string, packageJson: {
        name: string;
        version: string;
        description?: string;
    }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
    protected onRegister(_context: InterfacePluginContext): Promise<void>;
    protected onReady(_context: InterfacePluginContext): Promise<void>;
    protected onShutdown(): Promise<void>;
    protected getTools(): Promise<Tool[]>;
    protected getResources(): Promise<Resource[]>;
    protected getInstructions(): Promise<string | undefined>;
    getWebRoutes(): WebRouteDefinition[];
    requiresDaemonStartup(): boolean;
    ready(): Promise<void>;
    shutdown(): Promise<void>;
}

interface SendMessageToChannelRequest {
    /** The channel/room to send to (null for single-channel interfaces like CLI) */
    channelId: string | null;
    /** The message to send */
    message: string;
}
type SendMessageWithIdRequest = SendMessageToChannelRequest;
interface EditMessageRequest {
    channelId: string | null;
    messageId: string;
    newMessage: string;
}

declare abstract class MessageInterfacePlugin<TConfig = unknown, TTrackingInfo extends MessageJobTrackingInfo = MessageJobTrackingInfo> extends InterfacePlugin<TConfig, TTrackingInfo> {
    private readonly messageDelegate;
    protected constructor(id: string, packageJson: {
        name: string;
        version: string;
        description?: string;
    }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
    protected abstract sendMessageToChannel(request: SendMessageToChannelRequest): void;
    protected onRegister(_context: InterfacePluginContext): Promise<void>;
    protected onReady(_context: InterfacePluginContext): Promise<void>;
    protected onShutdown(): Promise<void>;
    protected getTools(): Promise<Tool[]>;
    protected getResources(): Promise<Resource[]>;
    protected getInstructions(): Promise<string | undefined>;
    protected sendMessageWithId(_request: SendMessageWithIdRequest): Promise<string | undefined>;
    protected editMessage(_request: EditMessageRequest): Promise<boolean>;
    protected supportsMessageEditing(): boolean;
    protected onProgressUpdate(_event: JobProgressEvent): Promise<void>;
    protected trackAgentResponseForJob(jobId: string, messageId: string, channelId: string): void;
    registerProgressCallback(callback: (events: JobProgressEvent[]) => void): void;
    unregisterProgressCallback(): void;
    getProgressEvents(): JobProgressEvent[];
    getActiveProgressEvents(): JobProgressEvent[];
    startProcessingInput(channelId?: string | null): void;
    endProcessingInput(): void;
    protected getCurrentChannelId(): string | null;
    ready(): Promise<void>;
    shutdown(): Promise<void>;
}

declare abstract class ServicePlugin<TConfig = unknown> implements Plugin {
    readonly type: "service";
    readonly id: string;
    readonly version: string;
    readonly packageName: string;
    readonly description?: string;
    private readonly delegate;
    protected constructor(id: string, packageJson: {
        name: string;
        version: string;
        description?: string;
    }, config: Partial<TConfig>, configSchema: z.ZodTypeAny);
    protected onRegister(_context: ServicePluginContext): Promise<void>;
    protected onReady(_context: ServicePluginContext): Promise<void>;
    protected onShutdown(): Promise<void>;
    protected getTools(): Promise<Tool[]>;
    protected getResources(): Promise<Resource[]>;
    protected getInstructions(): Promise<string | undefined>;
    ready(): Promise<void>;
    shutdown(): Promise<void>;
}

export { AgentResponseSchema, AnchorProfileSchema, AppInfoSchema, BaseMessageSchema, BrainCharacterSchema, ChatContextSchema, ConversationSchema, EntityPlugin, ExtensionMetadataSchema, InterfacePlugin, MessageInterfacePlugin, MessageResponseSchema, MessageSchema, PendingConfirmationSchema, ServicePlugin, ToolResultDataSchema, createResource, createTool, defineChannel, toolError, toolSuccess, urlCaptureConfigSchema };
export type { AgentNamespace, AgentResponse, AnchorProfile, AppInfo, BaseJobTrackingInfo, BaseMessage, BasePluginContext, BrainCharacter, Channel, ChatContext, Conversation, EntityPluginContext, ExtensionMetadata, IConversationsNamespace, IEntitiesNamespace, IEntityService, IEvalNamespace, IIdentityNamespace, IInsightsNamespace, IMessagingNamespace, IPromptsNamespace, IRuntimeUploadsNamespace, IServiceTemplatesNamespace, IViewsNamespace, InterfacePluginContext, JobProgressContext, JobProgressEvent, JobProgressStatus, Message, MessageContext, MessageJobTrackingInfo, MessageResponse, MessageRole, MessageSendOptions, MessageSender, MessageWithPayload, PendingConfirmation, Plugin, PluginConfig, PluginConfigInput, PluginFactory, Prompt, ResolvedRuntimeUpload, Resource, ResourceTemplate, RuntimeUploadRecord, RuntimeUploadResponseBody, RuntimeUploadScopeOptions, RuntimeUploadStore, SaveRuntimeUploadInput, ServicePluginContext, Tool, ToolConfirmation, ToolContext, ToolResponse, ToolResultData, ToolVisibility };
