import { CommandArgument, CommandProcessor, CommandResult, EnsureAuthValidated, ProcessRunOptions } from '../../utils/types.js'; import { BaseCLICommand } from './baseCommand.js'; import { FlagConfig } from './cliArgv.js'; export declare const WORKING_DIRECTORY_ARGUMENT: CommandArgument; export declare const AUTH_ARGUMENT: CommandArgument; export declare const SOURCE_ARGUMENT: CommandArgument; /** Options for `SessionAwareCLICommand.executeSdkCommand`. */ export interface ExecuteSdkOptions { /** Fixed CLI tokens appended after mapped flags (before `--debug`), e.g. `['--output=json']`. */ fixedFlags?: readonly string[]; /** Require an auth alias up front and return `missingAuthResult()` when none resolves. */ requireAuth?: boolean; /** Explicit working directory (skips `getWorkingDirectory` / `requiresProject`). */ cwd?: string; /** Capture stdout whole and apply client-side `select` + bounding (`shapeEnvelopeResult`). */ envelope?: { select?: unknown; raw?: boolean; }; /** Skip `validateArgs` when the caller already validated before pre-flight work. */ validated?: boolean; /** Per-call process options (when `envelope` is not set). */ processOptions?: ProcessRunOptions; } /** * Resolve the auth alias for a command that contacts an instance: the explicit * alias, else the session alias, else the alias that lazy validation of * `SN_INSTANCE_URL` stores in the session (undefined when there is none). */ export declare function resolveAuthAlias(providedAuth: string | undefined, ensureAuthValidated: EnsureAuthValidated): Promise; /** * Why lazy validation of `SN_INSTANCE_URL` left no alias, with its next step: * it failed (`validation_error`) or found no usable matching profile * (`not_authenticated`). `undefined` when validation was skipped (no * `SN_INSTANCE_URL`) or succeeded, so only an unconfigured server falls back * to the CLI default profile. */ export declare function authValidationFailureMessage(): string | undefined; /** The outcome of {@link resolveAuthOrFailure}: an alias, or why there is none. */ export interface AuthResolution { alias?: string; /** Set when `SN_INSTANCE_URL` is configured but resolved no alias. */ failure?: string; } /** * Resolve the auth alias as {@link resolveAuthAlias} does and, when none * resolves, report why lazy validation failed. A caller that would otherwise * run without `--auth` must stop on `failure`: the CLI would fall back to its * default profile, which may name an unrelated instance. */ export declare function resolveAuthOrFailure(providedAuth: string | undefined, ensureAuthValidated: EnsureAuthValidated): Promise; /** * Base class for commands that operate inside a Fluent project directory. * Extends BaseCLICommand and adds working directory handling, auth resolution, and timeout support. */ export declare abstract class SessionAwareCLICommand extends BaseCLICommand { private readonly ensureAuthValidated; constructor(commandProcessor: CommandProcessor, ensureAuthValidated?: EnsureAuthValidated); /** * Resolve the Fluent project directory without guessing from process cwd or the * installed package location. * * Resolution order: explicit `workingDirectory` argument → initialized session * → `FLUENT_MCP_WORKING_DIR` → undefined (the caller turns that into an * actionable error). * @returns The working directory to use for the command */ protected getWorkingDirectory(explicitWorkingDirectory?: unknown): string | undefined; /** * Resolve the auth alias for a command that requires instance access: the * explicit value, else the session alias (lazily validated on first use). * @param providedAuth Explicit auth alias from command args * @returns The resolved auth alias, or undefined if none available */ protected resolveAuthAlias(providedAuth?: string): Promise; /** * The failure of an instance command that found no auth alias, naming the * ways to provide one. */ protected missingAuthResult(): CommandResult; /** * Execute an SDK command with argument mapping to CLI flags. * Automatically resolves auth from session when 'auth' is in flagMapping but not provided in args. * Uses resolveTimeoutMs(args) for process execution. * * A string flag config takes the argument's value (`--flag=value`). An object * config is a boolean flag: `true` emits the bare flag, and `false` emits the * yargs negation (`--no-`) only when marked `negatable`, the only way to * turn off a CLI flag that defaults to true. Without it, `false` emits nothing. * @param sdkCommand The SDK command name (e.g., 'build', 'install') * @param args The command arguments object * @param flagMapping Optional mapping of arg names to CLI flags * @param positionalArgs Optional positional arguments to append at the end * @param signal Optional abort signal from the MCP client (kills the child on cancel) * @param options Optional per-call process options (e.g. a raised stdout capture cap) * @returns The command result */ protected executeSdkCommand(sdkCommand: string | readonly string[], args: Record, flagMapping?: Record, positionalArgs?: readonly string[], signal?: AbortSignal, options?: ExecuteSdkOptions): Promise; /** * Whether the CLI command works in a Fluent project. A command that reads * nothing from its cwd sets this to false: it declares no `workingDirectory` * argument and `executeSdkCommand` spawns it in the installed package directory. */ protected readonly requiresProject: boolean; /** * The runner timeout for one invocation. Defaults to the command's static * timeoutMs; commands whose CLI accepts its own caller-tunable timeout override * this so the runner never kills the child before the CLI can report it. * `FLUENT_MCP_COMMAND_TIMEOUT_MS` still wins over the value returned here. * @param _args The (validated) command arguments * @returns The timeout in milliseconds, or undefined for the runner default */ protected resolveTimeoutMs(_args: Record): number | undefined; } //# sourceMappingURL=sessionAwareCommand.d.ts.map