import { z } from "zod"; import type { IBridge } from "./bridge.js"; import type { ProjectContext } from "./project.js"; /** * Elicit a deterministic, user-mediated form response via the MCP client. * The server blocks until the client returns one of accept / decline / cancel. * Returns null when the connected client did not advertise the `elicitation` * capability — handlers that rely on this gate must refuse to proceed in * that case rather than fall back to an agent-mediated approval. */ export type ElicitFn = (params: ElicitParams) => Promise; export interface ElicitParams { message: string; requestedSchema: { type: "object"; properties: Record; required?: string[]; }; } export type ElicitPrimitiveSchema = { type: "string"; title?: string; description?: string; enum?: string[]; enumNames?: string[]; default?: string; } | { type: "number" | "integer"; title?: string; description?: string; default?: number; } | { type: "boolean"; title?: string; description?: string; default?: boolean; }; export interface ElicitResult { action: "accept" | "decline" | "cancel"; content?: Record; } export interface ToolContext { bridge: IBridge; project: ProjectContext; /** Lazy accessor for the active flow registry. Returns the merged * built-in + ue-mcp.yml flows. Used by project(get_status) so agents * see which canonical sequences are pre-encoded for this project. */ getFlows?: () => Array<{ name: string; description?: string; }>; /** Lazy accessor for the loaded plugin set. Returns one PluginInfo per * entry in the user's `plugins:` array, active or skipped. Used by the * `plugins` introspection category. */ getPlugins?: () => PluginInfo[]; /** MCP elicitation gate. When defined, calling this blocks the active * tool invocation until the user responds in their MCP client UI. When * undefined, the connected client does not declare the elicitation * capability — handlers that need a deterministic user signal MUST * refuse instead of degrading to an agent-mediated channel. Used by * feedback(submit) to gate every GitHub post on real user approval. */ elicit?: ElicitFn; } export interface PluginInfo { name: string; version: string; actionPrefix: string; status: "active" | "skipped"; statusReason?: string; minServerVersion?: string; uePluginDependency?: string; uePluginPresent?: boolean; injected: Record; /** Categories this plugin contributes as new top-level MCP tools. */ provided: Record; knowledge: Record; flows: string[]; tasks: string[]; pkgDir: string; manifestPath: string; } export interface ToolDef { name: string; description: string; schema: Record; handler: (ctx: ToolContext, params: Record) => Promise; actions: Record; } export interface ActionSpec { description?: string; bridge?: string; mapParams?: (p: Record) => Record; handler?: (ctx: ToolContext, params: Record) => Promise; /** Override the bridge call timeout in milliseconds. Defaults to 30s. */ timeoutMs?: number; } export declare function categoryTool(name: string, summary: string, actions: Record, actionDocs?: string, extraSchema?: Record): ToolDef; export declare function bp(bridge: string, mapParams?: (p: Record) => Record): ActionSpec; export declare function bp(description: string, bridge: string, mapParams?: (p: Record) => Record): ActionSpec; export interface DirectiveMachine { /** Stable identifier for the directive kind (e.g. "workaround.feedback"). */ kind: string; /** What the agent is expected to do next, as discrete steps. */ requiredActions: string[]; /** Free-form metadata - counts, identifiers, payloads - specific to kind. */ context?: Record; } export interface DirectiveResponse { __directive: true; directive: string; machine?: DirectiveMachine; result: unknown; } export declare function directive(text: string, result: unknown, machine?: DirectiveMachine): DirectiveResponse; export declare function isDirectiveResponse(v: unknown): v is DirectiveResponse;