import type { RelayMessaging, RelayMessage, RelayMessageReaction, RelayAgentRegistration, RelayAgentType, RelayMessageAttachmentInput, RelayMessageBlock, RelayMessageMode, RelaySendChannelMessageInput, RelayWorkspaceInfo } from './messaging/index.js';
import { type AgentRelayActions, type ActionContext, type ActionHandle, type ActionPolicy, type ActionSchema } from './actions/index.js';
import type { DeliveryMode } from './delivery/index.js';
import type { RelayAgentHandle } from './listeners.js';
/**
 * A reference to an agent accepted by the high-level facade APIs. Agents may be
 * passed as a bare name/handle string, or as an object carrying any of
 * `name`, `handle`, `id`, and (for acting-as sends) `token`.
 */
export interface AgentRef {
    name?: string;
    handle?: string;
    id?: string;
    token?: string;
    type?: RelayAgentType;
    persona?: string;
    metadata?: Record<string, unknown>;
}
export type AgentLike = string | AgentRef;
/** Resolve an agent reference to its bare name (sigils such as `@`/`#` stripped). */
export declare function resolveAgentName(ref: AgentLike): string;
/** Resolve an agent reference to its auth token, when one is available (for acting-as sends). */
export declare function resolveAgentToken(ref: AgentLike | undefined): string | undefined;
export interface RelaySendMessageInput {
    /** `#channel`, `@handle` (DM), or an array of `@handle`s (group DM). */
    to: string | string[];
    from?: AgentLike;
    text?: string;
    /** README shorthand for `text`. */
    msg?: string;
    mentions?: AgentLike[];
    mode?: RelayMessageMode;
    attachments?: RelayMessageAttachmentInput[];
    blocks?: RelayMessageBlock[];
    idempotencyKey?: string;
}
export interface RelayReplyInput {
    messageId?: string;
    thread?: string | {
        id?: string;
        threadId?: string;
    };
    from?: AgentLike;
    text: string;
    blocks?: RelayMessageBlock[];
    idempotencyKey?: string;
}
export interface RelayReactInput {
    message: string | {
        id: string;
    };
    agent?: AgentLike;
    emoji: string;
}
export interface RelayDirectInput {
    to: string;
    from?: AgentLike;
    text?: string;
    msg?: string;
    attachments?: RelayMessageAttachmentInput[];
    mode?: RelayMessageMode;
    idempotencyKey?: string;
}
/** Messaging surface plus the high-level overloads documented in the README. */
export type EnrichedMessages = RelayMessaging['messages'] & {
    send(input: RelaySendChannelMessageInput | RelaySendMessageInput): Promise<RelayMessage>;
    reply(input: RelayReplyInput): Promise<RelayMessage>;
    react(input: RelayReactInput): Promise<RelayMessageReaction>;
    react(messageId: string, emoji: string): Promise<RelayMessageReaction>;
    dm(input: RelayDirectInput): Promise<RelayMessage>;
};
/** Emoji reaction input on the live agent client. */
export interface RelayClientReactInput {
    messageId: string;
    emoji: string;
}
/**
 * A live, registered agent. Returned by `relay.workspace.register(...)` /
 * `reconnect(...)` and by harness `create(...)`. Carries the agent's identity
 * and status/tool predicate builders alongside a messaging surface scoped to
 * that agent.
 */
export interface RelayAgentClient extends RelayAgentHandle {
    readonly agents: RelayMessaging['agents'];
    readonly channels: RelayMessaging['channels'];
    readonly messages: EnrichedMessages;
    readonly threads: RelayMessaging['threads'];
    readonly inbox: RelayMessaging['inbox'];
    sendMessage(input: RelaySendMessageInput): Promise<RelayMessage>;
    reply(input: RelayReplyInput): Promise<RelayMessage>;
    react(input: RelayClientReactInput): Promise<RelayMessageReaction>;
}
/** Dependencies that let the workspace facade mint live agent clients. */
export interface WorkspaceFacadeDeps {
    buildAgentClient(registration: RelayAgentRegistration): RelayAgentClient;
    reconnectAgent(apiToken: string): Promise<RelayAgentClient>;
}
export interface RelayWorkspace {
    register<T extends AgentLike | AgentLike[]>(agents: T): Promise<T extends AgentLike[] ? RelayAgentClient[] : RelayAgentClient>;
    reconnect(input: {
        apiToken: string;
    }): Promise<RelayAgentClient>;
    info(): Promise<RelayWorkspaceInfo>;
}
export interface NotifyOptions {
    type?: string;
    action?: string;
    subject?: AgentLike;
    delivery?: DeliveryMode;
    text?: string;
}
export type NotifyHandler = (event?: unknown) => Promise<void>;
export interface RegisterActionInput<TInput = unknown, TOutput = unknown> {
    name: string;
    description?: string;
    input?: ActionSchema<TInput>;
    inputSchema?: ActionSchema<TInput>;
    output?: ActionSchema<TOutput>;
    outputSchema?: ActionSchema<TOutput>;
    visibility?: 'agent' | 'human' | 'internal';
    /** Restrict which agents may invoke this action. Omit to allow everyone. */
    availableTo?: AgentLike[];
    policy?: ActionPolicy;
    handler(args: {
        input: TInput;
        agent: ActionContext['caller'];
        ctx: ActionContext;
    }): Promise<TOutput> | TOutput;
}
/**
 * Resolves the messaging client to act through for a given `from` agent. When
 * the agent carries a token, sends are attributed to that agent; otherwise the
 * default (workspace) messaging client is used.
 */
export type MessagingResolver = (from: AgentLike | undefined) => RelayMessaging['messages'];
export declare function createEnrichedMessages(base: RelayMessaging['messages'], resolveFrom: MessagingResolver): EnrichedMessages;
export declare function createWorkspaceFacade(messaging: RelayMessaging, deps?: WorkspaceFacadeDeps): RelayWorkspace;
/**
 * Optional relay wiring for {@link registerFacadeAction}. When present and the
 * messaging client carries an agent-scoped action surface, `registerAction`
 * additionally registers the descriptor on the relay and subscribes the handler
 * agent to `action.invoked` so it can run the handler and post the result back.
 */
export interface ActionRelayWiring {
    messaging: RelayMessaging;
    /** The agent that owns and runs the handler (descriptor `handler_agent`). */
    handlerAgent?: string;
}
export declare function registerFacadeAction<TInput, TOutput>(actions: AgentRelayActions, def: RegisterActionInput<TInput, TOutput>, wiring?: ActionRelayWiring): ActionHandle;
export declare function createNotifyHandler(messages: EnrichedMessages, target: AgentLike, options: NotifyOptions): NotifyHandler;
//# sourceMappingURL=facade.d.ts.map