import { OperationId } from '../contract/types.js'; import { OperationTrackedSupport } from '../contract/metadata-types.js'; import { InlinePropertyStorage, InlinePropertyType, InlineRunPatchKey } from '../format/inline-run-patch.js'; import { SDHtmlMarkdownSupportCheckInput, SDHtmlMarkdownSupportCheckResult } from './html-markdown-support.js'; export declare const CAPABILITY_REASON_CODES: readonly ["COMMAND_UNAVAILABLE", "HELPER_UNAVAILABLE", "OPERATION_UNAVAILABLE", "TRACKED_MODE_UNAVAILABLE", "DRY_RUN_UNAVAILABLE", "NAMESPACE_UNAVAILABLE", "STYLES_PART_MISSING", "COLLABORATION_ACTIVE", "TARGET_CONTEXT_REQUIRED", "TARGET_UNSUPPORTED"]; export type CapabilityReasonCode = (typeof CAPABILITY_REASON_CODES)[number]; /** * A boolean flag indicating whether a capability is active, with optional * machine-readable reason codes explaining why it is disabled. */ export type CapabilityFlag = { enabled: boolean; reasons?: CapabilityReasonCode[]; }; /** Per-operation runtime capability describing availability, tracked-mode, and dry-run support. */ export interface OperationRuntimeCapability { /** Explicit optional-policy support for trackChanges.decide; absence means unsupported. */ commentRetention?: readonly 'point'[]; available: boolean; tracked: boolean; /** * Detailed tracked-mode support. `tracked` remains true only for `always` * so existing callers keep a conservative, backward-compatible boolean. */ trackedSupport?: OperationTrackedSupport; dryRun: boolean; reasons?: CapabilityReasonCode[]; } export type CapabilitySupportDecision = { kind: 'supported'; } | { kind: 'unsupported'; code: CapabilityReasonCode; reason: string; } | { kind: 'requires-input'; code: 'TARGET_CONTEXT_REQUIRED'; reason: string; }; export interface OperationCapabilityResolveInput { operationId: OperationId; input?: unknown; options?: unknown; } export interface OperationCapabilityResolveResult { operationId: OperationId; available: CapabilitySupportDecision; tracked: CapabilitySupportDecision; dryRun: CapabilitySupportDecision; } export type OperationCapabilities = Record; /** Runtime capabilities exposed by the plan engine (mutations.apply / mutations.preview). */ export interface PlanEngineCapabilities { /** Step op codes the engine can execute (e.g., 'text.rewrite', 'format.apply'). */ supportedStepOps: readonly string[]; /** Proven targeting modes; operation-specific restrictions remain in unsupported cells. */ supportedTargets?: readonly string[]; /** Named unsupported combinations with stable, discoverable reasons. */ unsupported?: readonly { cell: string; reason: string; }[]; /** Non-uniform style resolution strategies available for `onNonUniform`. */ supportedNonUniformStrategies: readonly string[]; /** Mark names supported by setMarks; consult unsupported for step-specific restrictions. */ supportedSetMarks: readonly string[]; /** Regex selector limits enforced by the selector engine. Unsafe patterns are rejected. */ regex: { /** Maximum allowed text-selector regex pattern length. */ maxPatternLength: number; maxExecutionMs?: number; }; } /** * Complete runtime capability snapshot for a Document API editor instance. * * `global` contains namespace-level flags (track changes, comments, lists, dry-run). * `operations` contains per-operation availability details keyed by {@link OperationId}. * `planEngine` describes plan engine capabilities (step ops, style strategies, limits). */ /** Per-inline-property runtime capability for `format.apply`. */ export interface InlinePropertyCapability { /** Whether this specific property is currently executable. */ available: boolean; /** Whether this property supports tracked mode. */ tracked: boolean; /** API value shape for this property. */ type: InlinePropertyType; /** Runtime storage path used by the editor (mark or runAttribute). */ storage: InlinePropertyStorage; } /** Format capability snapshot: advertises per-property support for `format.apply`. */ export interface FormatCapabilities { /** Capability entry per canonical inline patch key. */ supportedInlineProperties: Record; } export interface DocumentApiCapabilities { global: { trackChanges: CapabilityFlag; comments: CapabilityFlag; lists: CapabilityFlag; dryRun: CapabilityFlag; history: CapabilityFlag; }; /** Format capability discovery for `format.apply`. */ format: FormatCapabilities; operations: OperationCapabilities; planEngine: PlanEngineCapabilities; } /** Engine-specific adapter that resolves runtime capabilities for the current editor instance. */ export interface CapabilitiesAdapter { get(): DocumentApiCapabilities; check?(input: SDHtmlMarkdownSupportCheckInput): Promise; resolve?(input: OperationCapabilityResolveInput): OperationCapabilityResolveResult; } /** * Delegates to the capabilities adapter to retrieve the current capability snapshot. * * @param adapter - The engine-specific capabilities adapter. * @returns The resolved capabilities for this editor instance. */ export declare function executeCapabilities(adapter: CapabilitiesAdapter): DocumentApiCapabilities; export declare function executeCapabilitiesCheck(adapter: CapabilitiesAdapter, input: SDHtmlMarkdownSupportCheckInput): Promise; export declare function executeCapabilitiesResolve(adapter: CapabilitiesAdapter, input: OperationCapabilityResolveInput): OperationCapabilityResolveResult;