/**
 * Create Application Use Case
 *
 * End-to-end "user clicked Create": derives a unique slug, scaffolds the
 * project folder via CreateProjectUseCase, persists a new Application
 * entity, and (optionally) kicks off the interactive agent session by
 * sending the application-creation prompt as the first chat message.
 *
 * Composing the prompt + first-message dispatch in this use case keeps
 * the presentation layer free of orchestration logic and lets every
 * surface (Web, CLI, TUI) get the same behavior from a single call.
 */
import type { Application } from '../../../domain/generated/output.js';
import type { IApplicationRepository } from '../../ports/output/repositories/application-repository.interface.js';
import type { IOperationLogRepository } from '../../ports/output/repositories/operation-log.repository.interface.js';
import type { IApplicationCreationPromptBuilder } from '../../ports/output/services/application-creation-prompt-builder.interface.js';
import type { IApplicationBriefStore } from '../../ports/output/services/application-brief-store.interface.js';
import type { IApplicationScaffolder } from '../../ports/output/services/application-scaffolder.interface.js';
import type { IInteractiveMessageRepository } from '../../ports/output/repositories/interactive-message-repository.interface.js';
import type { ILogger } from '../../ports/output/services/logger.interface.js';
import type { ISettingsProvider } from '../../ports/output/services/settings-provider.interface.js';
import type { CreateProjectUseCase } from '../projects/create-project.use-case.js';
import type { SendInteractiveMessageUseCase } from '../interactive/send-interactive-message.use-case.js';
import type { RunWorkflowUseCase } from '../workflows/run-workflow.use-case.js';
import type { IInteractiveSessionRepository } from '../../ports/output/repositories/interactive-session-repository.interface.js';
/**
 * Build the very first message the agent sees on turn 1. Carries the
 * user's verbatim request AND a hard directive to read the brief
 * BEFORE any other action. Kept short so the agent doesn't skim past
 * the directive — the real content lives in the brief file.
 *
 * Note that this string is NOT persisted to the chat UI — the user
 * only sees their raw request in the first bubble. This is the
 * agent-side kickoff text, injected via `agentKickoffOverride`.
 *
 * @param briefPath  Absolute path to the brief file. Lives OUTSIDE
 *                   the user's project (under `~/.shep/application-briefs/`)
 *                   so we don't pollute the scaffolded repo.
 * @param userMessage The user's verbatim request.
 */
export declare function buildKickoffDirective(args: {
    briefPath: string;
    userMessage: string;
}): string;
export interface CreateApplicationInput {
    description: string;
    agentType?: string;
    modelOverride?: string;
    /**
     * When set, the use case ALSO sends this as the first message of the
     * application's interactive chat session, wrapped with the full
     * application-creation prompt (Shep persona, mission, tech stack,
     * workflow, quality bar, definition of done). Pass the user's verbatim
     * request — wrapping happens internally via the injected prompt builder.
     */
    initialPrompt?: string;
}
export interface CreateApplicationResult {
    application: Application;
    repositoryPath: string;
}
/**
 * 6-character lowercase hex tag (~16M combinations). Appended to every
 * application slug so each one is unique on disk and in the DB without
 * needing a sequential lookup-and-retry against existing rows. Random
 * also avoids the failure mode where a stale folder (left over from a
 * deleted DB row) blocks recreation under the same description.
 *
 * Exported for unit testing.
 */
export declare function randomSlugTag(): string;
export declare class CreateApplicationUseCase {
    private readonly appRepo;
    private readonly createProject;
    private readonly promptBuilder;
    private readonly sendMessage;
    private readonly briefStore;
    private readonly runWorkflow;
    private readonly sessionRepo;
    private readonly scaffolder;
    private readonly messageRepo;
    private readonly operationLogRepo;
    private readonly logger;
    private readonly settingsProvider;
    constructor(appRepo: IApplicationRepository, createProject: CreateProjectUseCase, promptBuilder: IApplicationCreationPromptBuilder, sendMessage: SendInteractiveMessageUseCase, briefStore: IApplicationBriefStore, runWorkflow: RunWorkflowUseCase, sessionRepo: IInteractiveSessionRepository, scaffolder: IApplicationScaffolder, messageRepo: IInteractiveMessageRepository, operationLogRepo: IOperationLogRepository, logger: ILogger, settingsProvider: ISettingsProvider);
    /**
     * Resolve the agent type + model that this Application should be
     * pinned to. Resolution rules — settings is the SINGLE source of
     * truth; explicit overrides win over it; nothing is hardcoded:
     *
     *   1. Explicit `input.agentType` / `input.modelOverride` win when set.
     *   2. Otherwise the user's `settings.agent.type` and
     *      `settings.models.default` are used.
     *   3. If settings haven't been initialised yet (impossible in
     *      practice once onboarding runs, but kept defensive for the
     *      first run before the seed migration completes), the values
     *      flow through as `undefined`. In that case the per-app
     *      session resolver falls through to `AgentType.ClaudeCode` —
     *      see `AgentConfigResolver.resolveAgentType`.
     *
     * Persisting the resolved values onto the Application row means
     * downstream callers (`ChatTab`, `RunWorkflowUseCase`, the
     * `AgentConfigResolver`) all see a stable per-app pin instead of
     * silently falling back to settings on every message — which used
     * to surface the demo `dev` agent in interactive boots and crash
     * the session.
     */
    private resolveAgentAndModel;
    execute(input: CreateApplicationInput): Promise<CreateApplicationResult>;
    /**
     * Background pipeline that runs AFTER the Application row is
     * already persisted and the caller has returned. Owns the long-
     * running side effects (scaffold, optional workflow) so no
     * presentation layer has to block on them.
     *
     * Errors at any stage are caught and flip the Application row to
     * Error + setupComplete=false — never re-thrown, because there is
     * no caller left to receive them.
     */
    private dispatchScaffoldAndWorkflow;
    /**
     * Generate `<baseSlug>-<random>` candidates until both the DB has no row
     * with that slug AND CreateProjectUseCase reports the folder doesn't
     * exist. Retries up to MAX_ATTEMPTS times before giving up.
     */
    private allocateUniqueSlugAndScaffold;
}
//# sourceMappingURL=create-application.use-case.d.ts.map