/** * Strict, versioned configuration. * * Configuration is JSON and is never interpreted by a model. Unknown fields * are rejected so misspellings and future/legacy semantics cannot silently * weaken a run. Credentials are deliberately not part of the schema: provider * adapters must read them from their provider-specific environment variables. */ import type { Config, ProviderConfig, ProviderName } from "../core/types.ts"; export declare const CONFIG_FILENAME = "human-to-code.config.json"; export declare const CONFIG_SCHEMA_VERSION: 1; export type DocumentationMode = "local-first" | "offline"; export type SandboxEngine = "auto" | "docker" | "podman"; export interface ProviderConfigV1 extends ProviderConfig { /** Required acknowledgement whenever a non-default endpoint is configured. */ trustCustomEndpoint?: true; /** Name of an environment variable; never the credential value itself. */ apiKeyEnv?: string; /** * Conservative model-specific API rates used to reserve a worst-case cost * before every remote request. Remote adapters refuse to run without them. */ pricing?: ProviderPricingV1; } export interface ProviderPricingV1 { inputUsdPerMillionTokens: number; outputUsdPerMillionTokens: number; /** Required when both rates are intentionally zero. */ unmetered?: true; } export interface DocumentationConfigV1 { mode: DocumentationMode; /** Repository-relative paths containing project/private documentation. */ privatePaths: string[]; /** Extra official domains approved by the operator, without schemes/paths. */ officialDomains: string[]; /** Exact dependency/version URL mappings used only after local evidence. */ officialSources: OfficialDocumentationSourceV1[]; } export interface OfficialDocumentationSourceV1 { ecosystem: "react" | "nestjs" | "fastapi" | "rust"; dependency: string; version: string; url: string; } export interface PrivacyConfigV1 { /** Remote providers remain disabled until project-level consent is explicit. */ remoteProviderConsent: boolean; /** Telemetry is opt-in and is also disabled by DO_NOT_TRACK. */ telemetry: boolean; /** Repository-relative paths that must not enter a context manifest. */ excludedPaths: string[]; maxFileBytes: number; maxContextTokens: number; } export interface SandboxConfigV1 { required: boolean; engine: SandboxEngine; /** v1 never permits validation commands to access the network. */ network: "none"; } export interface BudgetConfigV1 { maxCostUsd: number; maxInputTokens: number; maxOutputTokens: number; maxRequests: number; maxRepairs: number; timeoutMs: number; } export interface DirectPlanningConfigV1 { /** Master switch. False restores exactly one model request per unit. */ enabled: boolean; /** * When true, a single batched classification pass decides which todo-eligible * units actually need a plan, so simple requests skip the per-unit todo call. * One cheap classification request replaces a todo request for every unit it * judges simple; failure falls back to planning the affected units. When * false, every todo-eligible unit is planned (the original behavior). */ adaptive: boolean; /** One shared blueprint request per run, before any file is generated. */ projectBlueprint: boolean; /** One todo-list request per whole-file unit. */ fileTodo: boolean; /** One todo-list request per inline `@human` marker. */ markerTodo: boolean; /** * Coding requests allowed for one unit. A second pass is issued only when the * deterministic coverage check finds unaddressed todo items, and is discarded * unless it keeps everything the previous pass already produced. Set to 1 to * code every unit in a single request. */ maxCodingPassesPerUnit: number; } export interface DirectConfigV1 { /** Bounded post-generation cross-file integration reconciliation. */ reconcileIntegrations: boolean; /** Deterministic cross-file reference checks. Adds no model requests. */ crossFileChecks: boolean; /** Shared blueprint, per-unit todo lists, and adaptive coding requests. */ planning: DirectPlanningConfigV1; } export type UnderspecifiedPolicy = "error" | "warn"; export interface CompilerConfigV1 { /** Master switch. False preserves the pre-compiler-mode behavior. */ enabled: boolean; /** Whether unresolved facets block generation or are emitted as warnings. */ onUnderspecified: UnderspecifiedPolicy; /** Opt-in model-backed diagnostics for requests outside the static rule table. */ semanticDiagnostics: boolean; /** Read and write `human-to-code.lock.json` in the project root. */ lockfile: boolean; /** Reuse matching cached artifacts instead of issuing generation requests. */ replayFromLock: boolean; /** Project vocabulary whose keys count as explicit facet values. */ vocabulary: Record; } export interface WorkspaceOverrideV1 { root: string; provider?: ProviderConfigV1; documentation?: Partial; privacy?: Partial; budgets?: Partial; } /** * ConfigV1 extends the alpha fields to avoid breaking programmatic callers * while adding the production safety policy. Project analysis, rather than * `language`, is authoritative for mixed-language workspaces. */ export interface ConfigV1 extends Omit { schemaVersion: typeof CONFIG_SCHEMA_VERSION; provider: ProviderConfigV1; workspaces: WorkspaceOverrideV1[]; documentation: DocumentationConfigV1; privacy: PrivacyConfigV1; sandbox: SandboxConfigV1; budgets: BudgetConfigV1; direct: DirectConfigV1; compiler: CompilerConfigV1; } type DeepReadonly = T extends (...args: never[]) => unknown ? T : T extends readonly (infer U)[] ? readonly DeepReadonly[] : T extends object ? { readonly [K in keyof T]: DeepReadonly; } : T; /** Frozen defaults. Callers receive a deep clone, never this object. */ export declare const DEFAULT_CONFIG: DeepReadonly; /** Thrown for malformed or unsafe config; messages are safe to show users. */ export declare class ConfigError extends Error { readonly name = "ConfigError"; } /** The configured default model id for a provider in this package release. */ export declare function defaultModelFor(name: ProviderName): string; /** Validate a custom endpoint without performing any network access. */ export declare function validateProviderBaseUrl(raw: string, provider: ProviderName, trusted: boolean): string; /** Validate an already-parsed schema-v1 object into a fully defaulted config. */ export declare function validateConfig(raw: unknown): ConfigV1; /** * Explicitly migrate the dependency-free 0.0.1 shape. It intentionally accepts * only the four known legacy keys and then validates the resulting v1 object. */ export declare function migrateLegacyConfig(raw: unknown): ConfigV1; /** * Load `/human-to-code.config.json`. A missing file returns cloned * defaults; unreadable, non-regular, symlinked, oversized, or legacy files fail. */ export declare function loadConfig(root: string): Promise<{ config: ConfigV1; fromFile: boolean; }>; /** Serialize a fresh schema-v1 default config for initialization. */ export declare function defaultConfigJson(): string; export {}; //# sourceMappingURL=config.d.ts.map