/**
 * AI Profile / Config / Snapshot canonical types.
 *
 * Spec authority:
 *   P-AISC-001~005  AIScopeRef identity
 *   D-AIPC-001~012  Three-tier AI configuration
 *   K-AIEXEC-001~005 Runtime execution contract
 *   S-AICONF-001~006 SDK surface contract
 */
import type { JsonObject } from '../internal/utils.js';
import type { RuntimeRouteBinding } from './runtime-route.js';
export type AIScopeKind = 'app' | 'mod' | 'module' | 'feature';
/** Canonical identity for an AI configuration scope. */
export type AIScopeRef = {
    kind: AIScopeKind;
    ownerId: string;
    surfaceId?: string;
};
export type AIRuntimeLocalProfileRef = {
    modId: string;
    profileId: string;
};
export type AIProfileCapabilityIntent = {
    binding?: RuntimeRouteBinding | null;
    localProfileRef?: AIRuntimeLocalProfileRef | null;
    params?: JsonObject;
};
/** Portable AI configuration template. Not a live config. */
export type AIProfile = {
    profileId: string;
    title: string;
    description: string;
    tags: string[];
    capabilities: Partial<Record<string, AIProfileCapabilityIntent>>;
};
/** Traceability reference to the profile that was last applied to an AIConfig. */
export type AIProfileRef = {
    profileId: string;
    title: string;
    appliedAt: string;
};
export type AIConfigCapabilities = {
    selectedBindings: Partial<Record<string, RuntimeRouteBinding | null>>;
    localProfileRefs: Partial<Record<string, AIRuntimeLocalProfileRef | null>>;
    selectedParams: Partial<Record<string, JsonObject>>;
};
/** Scope-bound live AI configuration. Keyed by AIScopeRef. */
export type AIConfig = {
    scopeRef: AIScopeRef;
    capabilities: AIConfigCapabilities;
    profileOrigin: AIProfileRef | null;
};
export { computeAIConfigDiff, computeAIConfigVersion, createAIConfigEvidence, snapshotAIConfig, } from './ai-config-diff.js';
export type MemoryEmbeddingSourceKind = 'cloud' | 'local';
export type MemoryEmbeddingCloudBindingRef = {
    kind: 'cloud';
    connectorId: string;
    modelId: string;
};
export type MemoryEmbeddingLocalBindingRef = {
    kind: 'local';
    targetId: string;
};
export type MemoryEmbeddingBindingRef = MemoryEmbeddingCloudBindingRef | MemoryEmbeddingLocalBindingRef;
export type MemoryEmbeddingConfig = {
    scopeRef: AIScopeRef;
    sourceKind: MemoryEmbeddingSourceKind | null;
    bindingRef: MemoryEmbeddingBindingRef | null;
    revisionToken: string;
    updatedAt: string;
};
export type MemoryEmbeddingResolutionState = 'missing' | 'resolved' | 'unresolved' | 'unavailable';
export type MemoryEmbeddingCanonicalBankStatus = 'unbound' | 'bound_equivalent' | 'bound_profile_mismatch' | 'rebuild_pending' | 'cutover_ready';
export type MemoryEmbeddingRuntimeState = {
    bindingIntentPresent: boolean;
    bindingSourceKind: MemoryEmbeddingSourceKind | null;
    resolutionState: MemoryEmbeddingResolutionState;
    resolvedProfileIdentity: string | null;
    canonicalBankStatus: MemoryEmbeddingCanonicalBankStatus;
    blockedReasonCode: string | null;
    operationReadiness: {
        bindAllowed: boolean;
        cutoverAllowed: boolean;
    };
    traceId?: string;
};
export type MemoryEmbeddingRuntimeTargetRef = {
    kind: 'agent-core';
    agentId: string;
};
export type MemoryEmbeddingRuntimeInput = {
    scopeRef: AIScopeRef;
    targetRef: MemoryEmbeddingRuntimeTargetRef;
};
export type MemoryEmbeddingBindOutcome = 'bound' | 'already_bound' | 'staged_rebuild' | 'rejected';
export type MemoryEmbeddingBindResult = {
    outcome: MemoryEmbeddingBindOutcome;
    blockedReasonCode: string | null;
    canonicalBankStatusAfter: MemoryEmbeddingCanonicalBankStatus;
    pendingCutover: boolean;
    traceId?: string;
};
export type MemoryEmbeddingCutoverOutcome = 'cutover_committed' | 'already_current' | 'not_ready' | 'rejected';
export type MemoryEmbeddingCutoverResult = {
    outcome: MemoryEmbeddingCutoverOutcome;
    blockedReasonCode: string | null;
    canonicalBankStatusAfter: MemoryEmbeddingCanonicalBankStatus;
    traceId?: string;
};
/** Evidence of config state at execution start time. */
export type AIConfigEvidence = {
    profileOrigin: AIProfileRef | null;
    capabilityBindingKeys: string[];
    configSnapshot: AIConfig;
    configHash: string;
};
/** Minimal conversation execution slice for AISnapshot embedding. */
export type AIConversationExecutionSlice = {
    executionId: string;
    createdAt: string;
    capability: string;
    selectedBinding: RuntimeRouteBinding | null;
    resolvedBinding: unknown;
    health: unknown;
    metadata: unknown;
    agentResolution: unknown;
};
/** Execution-time snapshot. Immutable after creation. */
export type AISnapshot = {
    executionId: string;
    scopeRef: AIScopeRef;
    configEvidence: AIConfigEvidence;
    conversationCapabilitySlice: AIConversationExecutionSlice;
    runtimeEvidence: AIRuntimeEvidence | null;
    createdAt: string;
};
/** Runtime-side execution evidence container. */
export type AIRuntimeEvidence = {
    schedulingJudgement: AISchedulingJudgement | null;
};
/** K-SCHED-001: Six-value scheduling judgement state. */
export type AISchedulingState = 'runnable' | 'queue_required' | 'preemption_risk' | 'slowdown_risk' | 'denied' | 'unknown';
/** K-SCHED-003: Occupancy snapshot at peek time. */
export type AISchedulingOccupancy = {
    globalUsed: number;
    globalCap: number;
    appUsed: number;
    appCap: number;
};
/** K-SCHED-007: Target-scoped resource hint. */
export type AISchedulingResourceHint = {
    estimatedVramBytes?: number | null;
    estimatedRamBytes?: number | null;
    estimatedDiskBytes?: number | null;
    engine?: string | null;
};
/** K-SCHED-002: Atomic scheduling evaluation target. */
export type AISchedulingEvaluationTarget = {
    capability: string;
    modId?: string | null;
    profileId?: string | null;
    resourceHint?: AISchedulingResourceHint | null;
};
/** K-SCHED-002: Scheduling preflight judgement result. */
export type AISchedulingJudgement = {
    state: AISchedulingState;
    detail: string | null;
    occupancy: AISchedulingOccupancy | null;
    resourceWarnings: string[];
};
/** The two canonical built-in first-run chat surface ids (P-AISC-006). */
export type BuiltInChatSurfaceId = 'nimi' | 'agent';
/** Create the default app-level scope ref for Phase 1. */
export declare function createDefaultAIScopeRef(): AIScopeRef;
/** Create the canonical Phase 1 mod workspace scope ref. */
export declare function createCanonicalModAIScopeRef(modId: string): AIScopeRef;
/** True when the scope matches the canonical Phase 1 mod workspace scope. */
export declare function isCanonicalModAIScopeRef(scopeRef: AIScopeRef | null | undefined, modId: string): boolean;
/** Assert that the caller provided the canonical Phase 1 mod workspace scope. */
export declare function assertCanonicalModAIScopeRef(scopeRef: AIScopeRef | null | undefined, modId: string): AIScopeRef;
/**
 * Create a canonical built-in first-run chat AIScopeRef (P-AISC-006).
 *
 * Produces the `feature` shape owned by `desktop.chat`:
 *   - `nimi`  -> { kind: 'feature', ownerId: 'desktop.chat', surfaceId: 'nimi' }
 *   - `agent` -> { kind: 'feature', ownerId: 'desktop.chat', surfaceId: 'agent' }
 *
 * The caller must pass an explicit surface id. There is no omitted-scope
 * inference and the result is never the generic `DEFAULT_SCOPE`.
 */
export declare function createBuiltInChatAIScopeRef(surfaceId: BuiltInChatSurfaceId): AIScopeRef;
/** True when the scope is exactly one of the two canonical built-in chat scopes. */
export declare function isBuiltInChatAIScopeRef(scopeRef: AIScopeRef | null | undefined): boolean;
/**
 * Assert that the caller provided an exact canonical built-in chat scope.
 *
 * Rejects: omitted/null scope, generic `app:desktop:chat`, the retired
 * `app:desktop.chat.nimi|agent` shape, a merged `desktop.chat` scope with no
 * `surfaceId`, and any other non-canonical key. SDK never infers the scope.
 */
export declare function assertBuiltInChatAIScopeRef(scopeRef: AIScopeRef | null | undefined): AIScopeRef;
/** The canonical first-run built-in chat scope set, in stable order (P-AISC-006). */
export declare function builtInChatAIScopeRefs(): AIScopeRef[];
/**
 * One backend-issued durable built-in AIConfig evidence ref.
 *
 * The SDK keeps `ref` opaque: it does not mint, parse, or string-validate it.
 * Verification belongs to the Desktop host AIConfig service (D-AIPC-013).
 */
export type BuiltInAiConfigEvidenceRef = {
    scopeRef: AIScopeRef;
    ref: string;
};
/** Result of a first-run built-in AIConfig finalization apply (S-AICONF-007). */
export type FirstRunBuiltInAiConfigResult = {
    builtInAiConfigRefs: BuiltInAiConfigEvidenceRef[];
};
/**
 * Apply the selected first-run baseline AIProfile to a single explicit
 * canonical built-in chat scope, delegating durable evidence minting to the
 * host AIConfig service (S-AICONF-007).
 *
 * The `applyHostAiConfig` callback is the Desktop host AIConfig authority seam:
 * it owns atomic apply (D-AIPC-005) and returns the host/backend-issued durable
 * evidence ref. The SDK never mints the ref, never accepts a caller-provided
 * string as evidence, and never infers the scope from an omitted argument.
 */
export declare function applyFirstRunBuiltInChatAIConfig(input: {
    scopeRef: AIScopeRef;
    profile: AIProfile;
    applyHostAiConfig: (boundScopeRef: AIScopeRef, profile: AIProfile) => Promise<string>;
}): Promise<BuiltInAiConfigEvidenceRef>;
/**
 * Apply the selected first-run baseline AIProfile to BOTH canonical built-in
 * chat scopes (`desktop.chat.nimi` and `desktop.chat.agent`) and collect the
 * host-issued durable evidence refs (S-AICONF-007 / D-AIPC-013).
 *
 * Fails closed if either scope's apply fails — no partial built-in set is
 * returned. The generic `DEFAULT_SCOPE` is never reachable from this path.
 */
export declare function applyFirstRunBuiltInChatAIConfigs(input: {
    profile: AIProfile;
    applyHostAiConfig: (boundScopeRef: AIScopeRef, profile: AIProfile) => Promise<string>;
}): Promise<FirstRunBuiltInAiConfigResult>;
/** Create an empty AIConfig for a given scope. */
export declare function createEmptyAIConfig(scopeRef?: AIScopeRef): AIConfig;
/** Create an empty adjacent memory-embedding config for a given scope. */
export declare function createEmptyMemoryEmbeddingConfig(scopeRef?: AIScopeRef): MemoryEmbeddingConfig;
export type AIProbeStatus = 'available' | 'unavailable' | 'degraded' | 'unknown';
export type AIConfigProbeResult = {
    status: AIProbeStatus;
    capabilityStatuses: Partial<Record<string, AIProbeStatus>>;
    schedulingJudgement?: AISchedulingJudgement | null;
};
export type AIProfileApplyResult = {
    success: boolean;
    config: AIConfig | null;
    failureReason: string | null;
    probeWarnings: string[];
};
export type AIProfileValidationResult = {
    valid: boolean;
    errors: string[];
};
/** One field-level before→after change inside an AIConfig diff. */
export type AIConfigFieldDiff = {
    /** Dot-path of the changed materialized field, e.g. `capabilities.selectedBindings.text.generate`. */
    path: string;
    changeKind: 'added' | 'removed' | 'changed';
    before: unknown;
    after: unknown;
};
/**
 * Typed before→after diff of a `D-AIPC-005` apply (D-AIPC-014).
 *
 * Covers the full materialized `AIConfig` shape (`capabilities`,
 * `profileOrigin`, and any other materialized fields) — never a free-form
 * summary or a partial field subset.
 */
export type AIConfigDiff = {
    /** True when `before` and `after` are byte-equivalent (no-op apply). */
    identical: boolean;
    fields: AIConfigFieldDiff[];
};
/**
 * Result of a non-committing profile apply preview (D-AIPC-014 / S-AICONF-008).
 *
 * `previewApply` returns this without mutating live config, notifying
 * subscribers, or recording a snapshot. The caller still commits via
 * `aiProfile.apply`.
 */
export type AIProfilePreviewResult = {
    /** Current AIConfig for the scope, or `null` on first apply (full creation). */
    before: AIConfig | null;
    /** Full-materialization overwrite result that `D-AIPC-005` apply would write. */
    after: AIConfig;
    /** Typed before→after diff covering all materialized AIConfig fields. */
    diff: AIConfigDiff;
    /**
     * Content hash / version of `before` (or of an empty config when `before`
     * is null) so the caller can detect a stale preview before commit.
     */
    baseVersion: string;
    /** Typed availability / feasibility warnings; advisory, never block the diff. */
    probeWarnings: string[];
};
/** Profile catalog and apply operations. */
export type AIProfileSurface = {
    list(): Promise<AIProfile[]>;
    get(profileId: string): Promise<AIProfile | null>;
    validate(profile: AIProfile): AIProfileValidationResult;
    /**
     * Compute (without committing) the typed before→after `AIConfig` diff that a
     * `D-AIPC-005` apply would produce for `scopeRef` + `profileId`
     * (D-AIPC-014 / S-AICONF-008). Does not mutate live config, notify
     * subscribers, or record a snapshot. Fails closed on schema-invalid input.
     */
    previewApply(scopeRef: AIScopeRef, profileId: string): Promise<AIProfilePreviewResult>;
    apply(scopeRef: AIScopeRef, profileId: string): Promise<AIProfileApplyResult>;
    resolveLocalDependencies(profileId: string): Promise<unknown[]>;
};
/** Scope-bound config read/write operations. */
export type AIConfigSurface = {
    get(scopeRef: AIScopeRef): AIConfig;
    update(scopeRef: AIScopeRef, config: AIConfig): void;
    listScopes(): AIScopeRef[];
    probe(scopeRef: AIScopeRef): Promise<AIConfigProbeResult>;
    probeFeasibility(scopeRef: AIScopeRef): Promise<AIConfigProbeResult>;
    probeSchedulingTarget(scopeRef: AIScopeRef, target: AISchedulingEvaluationTarget): Promise<AISchedulingJudgement | null>;
    subscribe(scopeRef: AIScopeRef, callback: (config: AIConfig) => void): () => void;
};
/** Execution snapshot record/read operations. */
export type AISnapshotSurface = {
    record(scopeRef: AIScopeRef, snapshot: AISnapshot): void;
    get(executionId: string): AISnapshot | null;
    getLatest(scopeRef: AIScopeRef): AISnapshot | null;
};
export type MemoryEmbeddingConfigSurface = {
    get(scopeRef: AIScopeRef): MemoryEmbeddingConfig;
    update(scopeRef: AIScopeRef, config: MemoryEmbeddingConfig): void;
    subscribe(scopeRef: AIScopeRef, callback: (config: MemoryEmbeddingConfig) => void): () => void;
};
export type MemoryEmbeddingRuntimeSurface = {
    inspect(input: MemoryEmbeddingRuntimeInput): Promise<MemoryEmbeddingRuntimeState>;
    requestBind(input: MemoryEmbeddingRuntimeInput): Promise<MemoryEmbeddingBindResult>;
    requestCutover(input: MemoryEmbeddingRuntimeInput): Promise<MemoryEmbeddingCutoverResult>;
};
/** Aggregate SDK AI config surface (S-AICONF-001~006). */
export type AIConfigSDKSurface = {
    aiProfile: AIProfileSurface;
    aiConfig: AIConfigSurface;
    aiSnapshot: AISnapshotSurface;
};
/**
 * Apply an AIProfile to an AIConfig via atomic overwrite (D-AIPC-005).
 * Returns a new AIConfig with the profile's capability intents materialized.
 * The original config's scopeRef is preserved.
 */
export declare function applyAIProfileToConfig(config: AIConfig, profile: AIProfile): AIConfig;
/** Static schema validation for AIProfile (D-AIPC-012 layer 1). */
export declare function validateAIProfile(profile: unknown): AIProfileValidationResult;
/** Create a canonical execution ID for AISnapshot records. */
export declare function createAISnapshotExecutionId(nowMs?: number): string;
/** Create a canonical AISnapshot record using the published SDK schema. */
export declare function createAISnapshotRecord(input: {
    scopeRef?: AIScopeRef;
    config: AIConfig;
    capability: string;
    selectedBinding: RuntimeRouteBinding | null;
    resolvedBinding?: unknown;
    health?: unknown;
    metadata?: unknown;
    agentResolution?: unknown;
    runtimeEvidence?: AIRuntimeEvidence | null;
    executionId?: string;
    createdAt?: string;
}): AISnapshot;
//# sourceMappingURL=ai-config.d.ts.map