import type { WizardAnswers, WizardPlan } from "./wizard/answers.js"; import type { FirstRunManagedMemoryHooks } from "./first-run-managed-memory.js"; export interface InitMonoAgentFolderOptions { /** Folder the agent is constructed in. Defaults to process.cwd(). */ readonly dir?: string; /** The composed capability selection; omitted → {@link defaultAnswers} (the silent default scaffold). */ readonly answers?: WizardAnswers; /** Plan the scaffold and report it without writing anything. */ readonly dryRun?: boolean; /** Required capability secrets held only for this init run; never written to config JSON. */ readonly secretValues?: Readonly>; /** Recheck and harden an existing credential-bearing `.env` even when no new value is written. */ readonly secureExistingDotenv?: boolean; /** Guided-first-run guard: atomically create config and fail if another writer won the path. */ readonly requireConfigCreation?: boolean; /** Effective CLI environment used only to reject identity-changing memory overrides. */ readonly env?: Readonly>; /** @internal Test-only fault/race seams for first-run managed-memory publication. */ readonly firstRunManagedMemoryHooks?: FirstRunManagedMemoryHooks; } export interface InitMonoAgentFolderResult { readonly dir: string; readonly configPath: string; readonly identityPath: string; /** Exact outcome for the wizard Role's one canonical destination. */ readonly identityRole: { readonly path: string; readonly section: "## Role"; /** `preserved` means the entered Role was not written anywhere. */ readonly status: "created" | "preserved" | "planned-create"; }; /** Files and directories created (or, with dryRun, that would be created). */ readonly created: readonly string[]; /** Files that already existed and were left untouched (absolute paths). */ readonly skipped: readonly string[]; /** Existing knowledge files the generated identity references. */ readonly knowledgeFiles: readonly string[]; /** True when nothing was written because dryRun was set. */ readonly dryRun: boolean; /** True when this init securely merged in-run required secrets into `.env`. */ readonly secretsPersisted: boolean; /** Precise per-path outcomes, including updates that the legacy arrays cannot represent. */ readonly changes: readonly InitFileChange[]; /** The outcome of the optional secure `.env` persistence operation. */ readonly secretPersistence: SecretPersistenceOutcome; /** The composed plan (config, secrets, env example, files, validate expectations). */ readonly plan: WizardPlan; } export type InitFileChangeKind = "created" | "updated" | "unchanged" | "planned-create" | "planned-update"; export interface InitFileChange { readonly path: string; readonly kind: InitFileChangeKind; /** Marks a path whose contents must never be printed as part of init reporting. */ readonly sensitive?: boolean; } export type SecretPersistenceStatus = "not-requested" | "planned" | "persisted" | "refused"; export interface SecretPersistenceOutcome { readonly status: SecretPersistenceStatus; readonly path?: string; /** Whether at least one supplied value would be or was written. */ readonly changed: boolean; /** Stable refusal code suitable for programmatic recovery handling. */ readonly reason?: SecretEnvRefusalCode; /** Non-secret operator guidance, including an external lock/recovery path when relevant. */ readonly detail?: string; } export type SecretEnvRefusalCode = "git-safety-unavailable" | "invalid-secret-name" | "malformed-env" | "malformed-gitignore" | "owner-only-permissions-unsupported" | "tracked-env" | "unrepresentable-secret-value" | "unsafe-env-path" | "unsafe-gitignore-path" | "unsafe-lock-path"; export declare class SecretEnvPersistenceRefusedError extends Error { readonly code: SecretEnvRefusalCode; constructor(code: SecretEnvRefusalCode, message: string); } export declare class SecretEnvConcurrentModificationError extends Error { readonly ownerPid: number | undefined; readonly ownerCreatedAt: string | undefined; readonly recoveryPath: string | undefined; constructor(path: string, owner?: { readonly pid: number; readonly createdAt: string; }, recoveryPath?: string); } /** Recover the typed concurrency cause through bounded cleanup-error wrapping. */ export declare function secretEnvConcurrentModificationCause(error: unknown): SecretEnvConcurrentModificationError | undefined; export interface SecretEnvPersistenceOptions { /** Preview the exact safety checks and changes without writing. */ readonly dryRun?: boolean; /** Platform seam used to enforce the Windows fail-closed policy. */ readonly platform?: NodeJS.Platform; /** Filesystem capability seam; defaults to false on Windows and true elsewhere. */ readonly ownerOnlyPermissionsSupported?: boolean; /** Test seam invoked after a temporary file is durable and before optimistic verification. */ readonly beforeCommit?: (targetPath: string, temporaryPath: string) => void | Promise; /** Apply git/path/mode hardening to an existing file even when no values need merging. */ readonly secureExistingFile?: boolean; /** Test seam after all optimistic checks and immediately before identity-bound promotion. */ readonly beforePromotion?: (targetPath: string, temporaryPath: string) => void | Promise; /** Test seam after target claim and immediately before exclusive replacement link. */ readonly beforeInstallLink?: (targetPath: string, temporaryPath: string) => void | Promise; /** Test seam after exclusive replacement link and before claimed-inode cleanup. */ readonly afterInstallLink?: (targetPath: string, temporaryPath: string) => void | Promise; } export interface SecretEnvMergeResult { readonly changes: readonly InitFileChange[]; /** Number of supplied values that would be or were written. */ readonly valuesChanged: number; } /** * Non-destructively scaffolds a config-first mono-agent folder: a * `mono-agent.config.json` composed from the wizard answers (default scaffold when * none are supplied), an `IDENTITY.md` seeded from any knowledge files already in * the folder, the `.mono-agent/` working directories, and — when the composed plan * carries them — a `.env.example` and any capability files. Existing * scaffold/config files are never overwritten; reviewed secret persistence is * the deliberate exception that can transactionally replace `.env` and update * `.gitignore`. With `dryRun`, nothing is written and `created` reports what would * have been. */ export declare function initMonoAgentFolder(options?: InitMonoAgentFolderOptions): Promise; /** * Securely merge required secrets into `.env` without replacing non-empty * operator values. The destination and its git-ignore guard are preflighted, * then each changed file is committed through an exclusive same-directory * temporary file. The `.env` commit is always mode 0600 on supported systems. */ export declare function mergeSecretEnvFile(path: string, secretValues: Readonly>, options?: SecretEnvPersistenceOptions): Promise; /** Stable, repository-external lock path for one canonical dotenv target. */ export declare function secretEnvLockPathFor(path: string): Promise; /** Recheck the complete durable dotenv guard without changing either file. */ export declare function verifySecretEnvPersistenceGuard(path: string): Promise; //# sourceMappingURL=init.d.ts.map