/**
 * The tools of the modules, and the loader that puts them on the server.
 *
 * A module is a schema of its own, so its tools are named after it —
 * `fixed_assets_list`, `budgets_variance`, `crm_search` — and a model
 * reading a tool list can tell which module answers for what. The prefix is in `module.json`, and
 * a test holds the tool names to it.
 *
 * **Nothing here decides what is installed.** `public.modules` does, and the
 * server asks it at startup: a module whose migrations have never run has no
 * row, so its tools are not offered, and a tool a model cannot use is worse
 * than a tool it cannot see. What the registry below carries is the other
 * half — the handlers this release knows how to write — and a module installed
 * in the database that this release has no handlers for is simply not exposed.
 *
 * **PostgREST has to be told.** A schema other than `public` is served only
 * once the project lists it under its exposed schemas, which no migration can
 * set. The refusal that comes back is a 406 about a profile, which says
 * nothing useful to a model, so every module tool turns it into the sentence
 * that names the setting.
 */
import { z } from 'zod';
import { type Backend } from '../backend.js';
import { type EinvoiceTransport, type FiscalSystem } from '@ekwo-ai/core';
import type { ToolEffect } from './effect.js';
/** One module's tools, as the loader sees them. */
export interface ModuleToolset {
    /** The module code, and the key of `public.modules`. */
    code: string;
    /** Every tool of this module is `<prefix>_<verb>`. */
    prefix: string;
    /** The schema its objects live in, for the message when it is not exposed. */
    schema: string;
    tools: ModuleTool[];
    /** Its prompts, named `<prefix>_<name>` like its tools, offered with them. */
    prompts?: ModulePrompt[];
}
/** A checklist a module offers, filled in with the arguments the client passes. */
export interface ModulePrompt {
    name: string;
    title: string;
    description: string;
    /** Every argument is a string, described for the client. */
    args: Record<string, string>;
    text(args: Record<string, string>): string;
}
export interface ModuleTool {
    /** Without the prefix: `list`, `create`, `variance`. */
    verb: string;
    title: string;
    description: string;
    input: z.ZodObject<z.ZodRawShape>;
    /**
     * What it does to the books: `read`, `additive` or `destructive`, by the
     * rule of `packages/mcp/TOOL_DESIGN.md` — posting, replacing, removing or
     * reaching outside the books is destructive; making a draft, a record or a
     * setting a person can change back is additive.
     */
    effect: ToolEffect;
    /** Calling it twice with the same arguments does what calling it once did. */
    idempotent?: boolean;
    /** It reaches something outside the database: the transport of an electronic invoice. */
    openWorld?: boolean;
    run(backend: Backend, args: Record<string, never>, context: ModuleToolContext): Promise<unknown>;
}
/**
 * What the host hands a module tool beside the backend: things that are not
 * in the database and never will be. Today one — the transport an electronic
 * invoice leaves through, built by whoever runs the server with what it
 * needs, so no credential ever reaches a tool or a model.
 */
export interface ModuleToolContext {
    einvoiceTransport?: EinvoiceTransport;
    /** The invoicing system fiscal records are chained by, described by whoever runs the server. */
    fiscalSystem?: FiscalSystem;
}
/**
 * A schema the project has not exposed answers with a profile error, which
 * reads like a bug in this server. It is a setting, so say which one.
 */
export declare function inSchema<T>(schema: string, run: () => Promise<T>): Promise<T>;
/** Every module this release knows how to expose, by module code. */
export declare const MODULE_TOOLSETS: readonly ModuleToolset[];
/** The toolsets for a set of installed module codes, in a fixed order. */
export declare function toolsetsFor(installed: readonly string[]): ModuleToolset[];
/**
 * Which modules this installation carries.
 *
 * `public.modules` is the registry, and it is readable by anyone signed in —
 * it says what exists here, not what any company holds. A database that
 * predates the module framework has no such table, and the answer is then no
 * modules rather than an error.
 */
export declare function installedModules(backend: Backend): Promise<string[]>;
//# sourceMappingURL=modules.d.ts.map