import { Brand, Effect } from "effect";
import { type Executor as EffectExecutor, type InvokeOptions as EffectInvokeOptions } from "./executor";
import type { ElicitationContext, ElicitationResponse } from "./elicitation";
import type { FumaDb, FumaTables } from "./fuma-runtime";
import type { AnyPlugin } from "./plugin";
import type { CredentialProvider } from "./provider";
type Unbrand<T> = T extends Brand.Brand<string> ? string : T extends readonly (infer U)[] ? readonly Unbrand<U>[] : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Unbrand<K>, Unbrand<V>> : T extends ReadonlySet<infer U> ? ReadonlySet<Unbrand<U>> : T extends Date ? T : T extends (...args: infer A) => infer R ? (...args: {
    [I in keyof A]: Unbrand<A[I]>;
}) => Unbrand<R> : T extends object ? {
    readonly [K in keyof T]: Unbrand<T[K]>;
} : T;
export type PromiseOnElicitation = "accept-all" | ((ctx: Unbrand<ElicitationContext>) => ElicitationResponse | Promise<ElicitationResponse>);
export interface PromiseInvokeOptions {
    readonly onElicitation?: PromiseOnElicitation;
}
type PromisifiedArg<T> = T extends EffectInvokeOptions | undefined ? PromiseInvokeOptions | undefined : Unbrand<T>;
type PromisifiedArgs<TArgs extends readonly unknown[]> = {
    [I in keyof TArgs]: PromisifiedArg<TArgs[I]>;
};
export type Promisified<T> = T extends (...args: infer A) => Effect.Effect<infer R, infer _E> ? (...args: PromisifiedArgs<A>) => Promise<R> : T extends readonly unknown[] ? T : T extends object ? {
    readonly [K in keyof T]: Promisified<T[K]>;
} : T;
export type Executor<TPlugins extends readonly AnyPlugin[] = readonly []> = Promisified<EffectExecutor<TPlugins>>;
export interface ExecutorConfig<TPlugins extends readonly AnyPlugin[] = readonly []> {
    /** The org / workspace this executor binds to. Optional — defaults to
     *  `"default-tenant"`. `owner: "org"` rows file here. */
    readonly tenant?: string;
    /** The acting member. Omit for a pure-org executor (no `owner:"user"`). */
    readonly subject?: string;
    readonly plugins?: TPlugins;
    /**
     * Config-level credential providers, merged with every
     * `plugin.credentialProviders`. Config providers register first, so the
     * default (first writable) store is selected from them when present. A
     * writable provider is required before `connections.create({ value })` can
     * store an inline credential. Providers are Effect-native objects (their
     * `get`/`set` return `Effect`s) — bring them from `@executor-js/sdk/core`.
     */
    readonly providers?: readonly CredentialProvider[];
    /**
     * FumaDB ORM handle, or a factory that receives the executor-owned table
     * map. Public consumers usually want the factory form so `collectTables()`
     * stays inside `createExecutor`.
     */
    readonly db?: FumaDb | {
        readonly db: FumaDb;
        readonly close?: () => Promise<void> | void;
    } | ((config: {
        readonly tables: FumaTables;
    }) => FumaDb | {
        readonly db: FumaDb;
        readonly close?: () => Promise<void> | void;
    } | Promise<FumaDb | {
        readonly db: FumaDb;
        readonly close?: () => Promise<void> | void;
    }>);
    /**
     * How to respond when a tool requests user input mid-invocation. Pass
     * `"accept-all"` for tests / non-interactive hosts, or a handler
     * `(ctx) => Promise<ElicitationResponse>` for interactive ones.
     * Required at construction so per-invoke calls don't have to thread
     * an options arg.
     */
    readonly onElicitation: PromiseOnElicitation;
}
export declare const createExecutor: <const TPlugins extends readonly AnyPlugin[] = readonly []>(config: ExecutorConfig<TPlugins>) => Promise<Executor<TPlugins>>;
export {};
//# sourceMappingURL=promise-executor.d.ts.map