import type { PluginCommandContribution, PluginEditorExtensionContribution, PluginFileViewerContribution, PluginJobContribution, PluginMarkdownBlockConfigSchema, PluginMarkdownBlockRendererMode, PluginPermission, PluginNoteActionContribution, PluginNoteActionSurface, PluginRuntime, Sha256Digest } from "./manifest-types.js";
import type { PLUGIN_API_ERROR_CODES, PLUGIN_API_MAJOR_STRING, PLUGIN_API_VERSION } from "./constants.js";
export type JsonPrimitive = string | number | boolean | null;
export type JsonValue = JsonPrimitive | {
    readonly [key: string]: JsonValue;
} | readonly JsonValue[];
declare const bodyRevisionBrand: unique symbol;
declare const propertiesRevisionBrand: unique symbol;
declare const packageAssetUrlBrand: unique symbol;
/** Host-issued opaque token. Plugins can only echo it to body CAS mutations. */
export type BodyRevision = string & {
    readonly [bodyRevisionBrand]: "BodyRevision";
};
/** Host-issued opaque token. Plugins can only echo it to property CAS mutations. */
export type PropertiesRevision = string & {
    readonly [propertiesRevisionBrand]: "PropertiesRevision";
};
/** Scope-owned and revocable; its contents and URL scheme are host-private. */
export type PackageAssetUrl = string & {
    readonly [packageAssetUrlBrand]: "PackageAssetUrl";
};
export type PluginApiErrorCode = typeof PLUGIN_API_ERROR_CODES[number];
export interface BoundedPluginError {
    readonly code: PluginApiErrorCode;
    readonly message: string;
    readonly retryable: boolean;
}
export interface PluginIdentity {
    readonly id: string;
    readonly name: string;
    readonly version: string;
    readonly digest: Sha256Digest | null;
    readonly permissions: readonly PluginPermission[];
}
export interface PluginWorkspaceContext {
    readonly kind: "personal";
    /** Host-created, display-opaque scope identity; never a filesystem path. */
    readonly scopeId: string;
}
export interface PluginDisposable {
    dispose(): void;
}
export interface PluginThemeDto {
    readonly mode: "light" | "dark";
    readonly contrast: "normal" | "high";
}
export interface PluginNotePropertiesDto {
    readonly id: string;
    readonly title: string;
    readonly path: string;
    readonly values: Readonly<Record<string, JsonValue>>;
    readonly propertiesRevision: PropertiesRevision;
    /** Display/audit timestamp only. It is never a conditional-write token. */
    readonly updatedAt: string;
}
export interface PluginNoteDto extends PluginNotePropertiesDto {
    readonly body: string;
    readonly bodyRevision: BodyRevision;
}
export interface PluginNoteCreateInput {
    readonly title: string;
    readonly subdir?: string;
    readonly body?: string;
    readonly properties?: Readonly<Record<string, JsonValue>>;
}
export interface PluginPropertyMutation {
    readonly changes: Readonly<Record<string, JsonValue | null>>;
    readonly expectedPropertiesRevision: PropertiesRevision;
}
export interface PluginPropertyMutationResult {
    readonly id: string;
    readonly status: "updated" | "unchanged" | "stale" | "denied" | "failed";
    readonly propertiesRevision?: PropertiesRevision;
    readonly error?: BoundedPluginError;
}
export interface PluginPropertyBatchOperation extends PluginPropertyMutation {
    readonly id: string;
}
export interface PluginPropertyBatchOptions {
    readonly operation: string;
}
export interface PluginTextEdit {
    readonly from: number;
    readonly to: number;
    readonly insert: string;
}
export interface PluginTextMutation {
    readonly edits: readonly PluginTextEdit[];
    readonly expectedBodyRevision: BodyRevision;
}
export interface PluginTextMutationResult {
    readonly id: string;
    readonly status: "updated" | "unchanged" | "stale" | "denied" | "failed";
    readonly bodyRevision?: BodyRevision;
    readonly error?: BoundedPluginError;
}
export interface PluginNotesApi {
    get(id: string): Promise<PluginNoteDto | null>;
    create(input: PluginNoteCreateInput): Promise<PluginNoteDto>;
    updateProperties(id: string, mutation: PluginPropertyMutation): Promise<PluginPropertyMutationResult>;
    updatePropertiesBatch(operations: readonly PluginPropertyBatchOperation[], options: PluginPropertyBatchOptions): Promise<readonly PluginPropertyMutationResult[]>;
    applyTextEdits(id: string, mutation: PluginTextMutation): Promise<PluginTextMutationResult>;
    addTag(id: string, tag: string, expectedPropertiesRevision: PropertiesRevision): Promise<PluginPropertyMutationResult>;
    removeTag(id: string, tag: string, expectedPropertiesRevision: PropertiesRevision): Promise<PluginPropertyMutationResult>;
    rename(id: string, title: string, expectedPropertiesRevision: PropertiesRevision): Promise<PluginPropertyMutationResult>;
    move(id: string, subdir: string, expectedPropertiesRevision: PropertiesRevision): Promise<PluginPropertyMutationResult>;
    trash(id: string, expectedPropertiesRevision: PropertiesRevision): Promise<PluginPropertyMutationResult>;
}
export interface PluginBacklinkDto {
    readonly sourceId: string;
    readonly sourceTitle: string;
    readonly sourcePath: string;
    readonly blockId: string | null;
    readonly snippet: string;
}
export interface PluginBacklinkPageDto {
    readonly rows: readonly PluginBacklinkDto[];
    readonly cursor: string | null;
}
export interface PluginBacklinkPageOptions {
    readonly limit?: number;
    readonly cursor?: string | null;
}
export type PluginPropertyScalar = string | number | boolean;
export interface PluginPropertyValueLookupDto {
    readonly value: PluginPropertyScalar;
    readonly matches: readonly PluginNotePropertiesDto[];
}
export interface PluginPropertyValueLookupPageDto {
    readonly rows: readonly PluginPropertyValueLookupDto[];
    /** Populated only on the first page; private and unreadable notes do not satisfy a value. */
    readonly missingValues: readonly PluginPropertyScalar[];
    readonly cursor: string | null;
}
export interface PluginPropertyValueLookupRequest {
    readonly property: string;
    readonly values: readonly PluginPropertyScalar[];
    readonly limit?: number;
    readonly cursor?: string | null;
}
export interface PluginMetadataApi {
    get(id: string): Promise<PluginNotePropertiesDto | null>;
    resolveTitle(title: string): Promise<readonly PluginNotePropertiesDto[]>;
    getBacklinks(id: string, options?: PluginBacklinkPageOptions): Promise<PluginBacklinkPageDto>;
    getBlockBacklinks(id: string, blockId: string, options?: PluginBacklinkPageOptions): Promise<PluginBacklinkPageDto>;
    findByPropertyValues(request: PluginPropertyValueLookupRequest): Promise<PluginPropertyValueLookupPageDto>;
    subscribe(callback: (ids: readonly string[]) => void): PluginDisposable;
}
export interface PluginSearchRowDto {
    readonly kind: "note" | "bare-file" | "asset";
    readonly id: string | null;
    readonly title: string;
    readonly path: string;
    readonly properties: Readonly<Record<string, JsonValue>>;
    readonly propertiesRevision: PropertiesRevision | null;
}
export interface PluginSearchDiagnosticDto {
    readonly code: string;
    readonly message: string;
    readonly severity: "error" | "warning";
    readonly start: number | null;
    readonly end: number | null;
}
export interface PluginSearchDateContextDto {
    readonly now: string;
    readonly weekStart: "sunday" | "monday";
    readonly timeZone: string;
}
export interface PluginSearchPageDto {
    readonly rows: readonly PluginSearchRowDto[];
    readonly total: number;
    readonly cursor: string | null;
    readonly diagnostics: readonly PluginSearchDiagnosticDto[];
    readonly dateContext: PluginSearchDateContextDto;
}
export interface PluginSearchPageOptions {
    readonly limit?: number;
    readonly cursor?: string | null;
    readonly includeAssets?: boolean;
    readonly includeBare?: boolean;
    readonly signal?: AbortSignal;
}
export interface PluginSearchObserveRequest {
    readonly query: string;
    readonly pageSize?: number;
    readonly includeAssets?: boolean;
    readonly includeBare?: boolean;
    readonly visible?: boolean;
    /** A view-owned signal lets the host stop this controller before plugin-scope teardown. */
    readonly signal?: AbortSignal;
}
export interface PluginSearchApi {
    query(query: string, options?: PluginSearchPageOptions): Promise<PluginSearchPageDto>;
    observe(request: PluginSearchObserveRequest): PluginSearchController;
}
export type PluginSearchPresentationOptionField = {
    readonly type: "boolean";
    readonly title?: string;
    readonly description?: string;
    readonly default?: boolean;
} | {
    readonly type: "integer" | "number";
    readonly title?: string;
    readonly description?: string;
    readonly default?: number;
    readonly minimum?: number;
    readonly maximum?: number;
} | {
    readonly type: "string";
    readonly title?: string;
    readonly description?: string;
    readonly default?: string;
    readonly enum?: readonly string[];
    readonly minLength?: number;
    readonly maxLength?: number;
};
export interface PluginSearchPresentationOptionsSchema {
    readonly type: "object";
    readonly properties: Readonly<Record<string, PluginSearchPresentationOptionField>>;
    readonly required?: readonly string[];
    readonly additionalProperties: false;
}
export interface PluginSearchPresentationGroupDto {
    readonly key: string;
    readonly label: string;
    readonly parentGroup?: string;
    readonly rows: readonly PluginSearchRowDto[];
}
export interface PluginSearchPresentationSnapshot {
    /** Host-namespaced identity; configuration callbacks use the local manifest ID. */
    readonly presentationId: string;
    readonly viewId: string;
    readonly options: Readonly<Record<string, JsonValue>>;
    readonly rows: readonly PluginSearchRowDto[];
    readonly groups: readonly PluginSearchPresentationGroupDto[];
    readonly loaded: number;
    /** Currently loaded rows remaining after host-owned visual filters. */
    readonly total: number;
    /** Exact query total before host-owned visual filters. */
    readonly queryTotal: number;
    readonly hasNextPage: boolean;
    readonly selection: readonly string[];
}
export interface PluginSearchPresentationController {
    readonly snapshot: PluginSearchPresentationSnapshot;
    loadMore(): Promise<PluginSearchPresentationSnapshot>;
    retry(): void;
}
export interface PluginSearchPresentationHandle {
    onDataUpdated?(snapshot: PluginSearchPresentationSnapshot): void;
    destroy?(): void;
}
export interface NativePluginSearchApi extends PluginSearchApi {
    registerPresentation(registration: {
        readonly id: string;
        readonly title: string;
        readonly icon?: string;
        readonly options: PluginSearchPresentationOptionsSchema;
        create(controller: PluginSearchPresentationController, container: HTMLElement): PluginSearchPresentationHandle | void;
    }): PluginDisposable;
}
export interface PluginMarkdownBlockSourceNoteDto {
    readonly id: string;
}
export interface PluginMarkdownBlockRenderDto {
    readonly version: 1;
    readonly blockId: string;
    /** Host-derived `<plugin-id>:<local-id>` identity from the sidecar type. */
    readonly typeId: string;
    readonly configVersion: 1;
    readonly config: Readonly<Record<string, string | number | boolean>>;
    readonly sourceNote: PluginMarkdownBlockSourceNoteDto;
    readonly workspaceContext: PluginWorkspaceContext;
    readonly readOnly: boolean;
    readonly interactive: boolean;
}
export interface PluginMarkdownBlockHandle {
    destroy?(): void | Promise<void>;
}
interface PluginMarkdownBlockRegistrationBase {
    readonly id: string;
    readonly title: string;
    readonly runtime: PluginRuntime;
    readonly rendererMode: PluginMarkdownBlockRendererMode;
    readonly configSchema: PluginMarkdownBlockConfigSchema;
    readonly permissions: readonly PluginPermission[];
}
export interface NativePluginMarkdownBlockRegistration extends PluginMarkdownBlockRegistrationBase {
    readonly runtime: "native";
    readonly rendererMode: "native-imperative";
    render(container: HTMLElement, block: PluginMarkdownBlockRenderDto): PluginMarkdownBlockHandle | void | Promise<PluginMarkdownBlockHandle | void>;
}
export interface NativePluginMarkdownBlocksApi {
    register(registration: NativePluginMarkdownBlockRegistration): PluginDisposable;
}
/**
 * Opaque at the public contract boundary. Values are created only by methods
 * on the host-supplied module cohort and are interpreted by that same host
 * CodeMirror runtime.
 */
export interface NativePluginEditorExtension {
    readonly __thortiqHostEditorExtension?: never;
}
export interface NativePluginEditorExtensionModuleCohortV1 {
    readonly version: "1.0.0";
    readonly state: {
        readonly StateEffect: {
            define<T = unknown>(): {
                of(value: T): unknown;
            };
        };
        readonly StateField: {
            define<T>(spec: Readonly<Record<string, unknown>>): NativePluginEditorExtension;
        };
        readonly Facet: {
            define<Input = unknown, Output = readonly Input[]>(config?: Readonly<Record<string, unknown>>): {
                of(value: Input): NativePluginEditorExtension;
            };
        };
        readonly RangeSetBuilder: new <T = unknown>() => {
            add(from: number, to: number, value: T): void;
            finish(): unknown;
        };
    };
    readonly view: {
        readonly Decoration: {
            mark(spec: Readonly<Record<string, unknown>>): unknown;
            line(spec: Readonly<Record<string, unknown>>): unknown;
            widget(spec: Readonly<Record<string, unknown>>): unknown;
            replace(spec: Readonly<Record<string, unknown>>): unknown;
            set(ranges: readonly unknown[], sort?: boolean): unknown;
            readonly none: unknown;
        };
        readonly EditorView: {
            theme(spec: Readonly<Record<string, unknown>>, options?: {
                readonly dark?: boolean;
            }): NativePluginEditorExtension;
            baseTheme(spec: Readonly<Record<string, unknown>>): NativePluginEditorExtension;
            domEventHandlers(handlers: Readonly<Record<string, (...args: readonly unknown[]) => boolean | void>>): NativePluginEditorExtension;
            readonly updateListener: {
                of(callback: (update: unknown) => void): NativePluginEditorExtension;
            };
        };
        readonly ViewPlugin: {
            define(create: (view: unknown) => unknown, spec?: Readonly<Record<string, unknown>>): NativePluginEditorExtension;
            fromClass(value: new (view: unknown) => unknown, spec?: Readonly<Record<string, unknown>>): NativePluginEditorExtension;
        };
        readonly WidgetType: abstract new () => {
            eq?(other: unknown): boolean;
            toDOM(view: unknown): HTMLElement;
            destroy?(dom: HTMLElement): void;
        };
        readonly keymap: {
            of(bindings: readonly Readonly<Record<string, unknown>>[]): NativePluginEditorExtension;
        };
    };
    readonly language: {
        syntaxTree(state: unknown): unknown;
    };
}
export interface NativePluginEditorExtensionNoteContext {
    readonly id: string;
    readonly type: string;
}
export interface NativePluginEditorExtensionContextV1 {
    readonly version: "1.0.0";
    readonly contributionId: string;
    readonly note: NativePluginEditorExtensionNoteContext;
    readonly workspaceContext: PluginWorkspaceContext;
    readonly mode: "edit" | "read";
    readonly readOnly: boolean;
    readonly theme: PluginThemeDto;
    readonly configuration: Readonly<Record<string, string | number | boolean>>;
    readonly commands: {
        /** Runs only a command declared by the same plugin generation. */
        run(commandId: string, input?: JsonValue | null): Promise<void>;
    };
    readonly events: {
        /**
         * Pane-scoped context notification. The returned handle is removed before
         * the contribution is recreated, disabled, updated, or the pane closes.
         */
        onContextChange(callback: (context: NativePluginEditorExtensionContextV1) => void): PluginDisposable;
    };
}
export interface NativePluginEditorExtensionRegistration extends PluginEditorExtensionContribution {
    create(modules: NativePluginEditorExtensionModuleCohortV1, context: NativePluginEditorExtensionContextV1): NativePluginEditorExtension | readonly NativePluginEditorExtension[];
}
export interface NativePluginEditorExtensionsApi {
    register(registration: NativePluginEditorExtensionRegistration): PluginDisposable;
}
export interface PluginNoteActionNoteDto {
    readonly id: string;
    readonly title: string;
    readonly path: string;
    readonly type: string;
    readonly tags: readonly string[];
    readonly properties: Readonly<Record<string, JsonValue>>;
    readonly updatedAt: string;
}
export interface PluginNoteActionInvocationDto {
    readonly note: PluginNoteActionNoteDto;
    readonly surface: PluginNoteActionSurface;
    /** True only for the host event which opened/invoked the menu item. */
    readonly userGesture: true;
}
export interface PluginNoteActionInvocationContext {
    readonly signal: AbortSignal;
    /** The same frozen, permission-gated facade supplied during activation. */
    readonly api: PluginApiV1;
}
export interface NativePluginNoteActionRegistration extends PluginNoteActionContribution {
    run(invocation: PluginNoteActionInvocationDto, context: PluginNoteActionInvocationContext): void | Promise<void>;
}
export interface NativePluginNoteActionsApi {
    register(registration: NativePluginNoteActionRegistration): PluginDisposable;
}
export interface PluginFileViewerAssetDto {
    readonly path: string;
    readonly extension: string;
    readonly mediaType: string;
    readonly sizeBytes: number;
    readonly updatedAt: string;
}
export type PluginFileViewerContentDto = {
    readonly kind: "bytes";
    /** A fresh host-owned copy; mutation cannot affect the host or another pane. */
    readonly bytes: Uint8Array;
} | {
    readonly kind: "text";
    readonly text: string;
};
export interface PluginFileViewerMountDto {
    readonly asset: PluginFileViewerAssetDto;
    readonly content: PluginFileViewerContentDto;
    readonly initialState: JsonValue | null;
    readonly selection: "explicit" | "default";
}
export interface PluginFileViewerMountContext {
    readonly signal: AbortSignal;
    readonly api: PluginApiV1;
    publishState(state: JsonValue): void;
    setTitle(title: string): void;
}
export interface PluginFileViewerHandle {
    getState?(): JsonValue;
    destroy(): void | Promise<void>;
}
export interface NativePluginFileViewerRegistration extends PluginFileViewerContribution {
    mount(container: HTMLElement, input: PluginFileViewerMountDto, context: PluginFileViewerMountContext): PluginFileViewerHandle | void | Promise<PluginFileViewerHandle | void>;
}
export interface NativePluginFileViewersApi {
    register(registration: NativePluginFileViewerRegistration): PluginDisposable;
}
export interface PluginSearchController {
    readonly snapshot: PluginSearchPageDto;
    readonly diagnostics: readonly PluginSearchDiagnosticDto[];
    readonly hasNextPage: boolean;
    subscribe(callback: (snapshot: PluginSearchPageDto) => void): PluginDisposable;
    unsubscribe(callback: (snapshot: PluginSearchPageDto) => void): void;
    setVisible(visible: boolean): void;
    nextPage(): Promise<PluginSearchPageDto>;
    /** Alias retained for presentation code which describes forward paging as loading more. */
    loadMore(): Promise<PluginSearchPageDto>;
    retry(): void;
    destroy(): void;
}
export interface PluginAssetDto {
    readonly path: string;
    readonly mediaType: string | null;
    readonly sizeBytes: number;
    readonly updatedAt: string;
}
export interface PluginAssetPageOptions {
    readonly extensions?: readonly string[];
    readonly limit?: number;
    readonly cursor?: string | null;
    readonly signal?: AbortSignal;
}
export interface PluginAssetPageDto {
    readonly assets: readonly PluginAssetDto[];
    /** Exact filtered index total captured when the cursor chain starts. */
    readonly total: number;
    readonly cursor: string | null;
}
export interface PluginAssetReadOptions {
    readonly maxBytes: number;
    readonly signal?: AbortSignal;
}
export interface PluginAssetsApi {
    list(options?: PluginAssetPageOptions): Promise<PluginAssetPageDto>;
    readText(path: string, options: PluginAssetReadOptions): Promise<string>;
    readBytes(path: string, options: PluginAssetReadOptions): Promise<Uint8Array>;
    watch(path: string, callback: (asset: PluginAssetDto | null) => void): PluginDisposable;
}
export interface PluginWorkspaceApi {
    openNote(id: string, options?: {
        readonly newPane?: boolean;
    }): Promise<void>;
    openAsset(path: string, options?: {
        readonly newPane?: boolean;
    }): Promise<void>;
    openView(viewId: string, state?: JsonValue): Promise<void>;
    setViewTitle(instanceId: string, title: string): void;
    pushViewState(instanceId: string, state: JsonValue): void;
    getTheme(): PluginThemeDto;
    onThemeChange(callback: (theme: PluginThemeDto) => void): PluginDisposable;
}
export interface PluginDialogsApi {
    message(request: {
        readonly title: string;
        readonly message: string;
        readonly tone?: "info" | "warning" | "error";
    }): Promise<void>;
    confirm(request: {
        readonly title: string;
        readonly message?: string;
        readonly confirmLabel?: string;
        readonly cancelLabel?: string;
        readonly destructive?: boolean;
    }): Promise<boolean>;
    prompt(request: {
        readonly title: string;
        readonly message?: string;
        readonly defaultValue?: string;
        readonly placeholder?: string;
        readonly confirmLabel?: string;
        readonly cancelLabel?: string;
        readonly maxLength?: number;
    }): Promise<string | null>;
    /** @deprecated Use pickers.note(). */
    pickNote(request?: {
        readonly title?: string;
        readonly query?: string;
    }): Promise<string | null>;
    /** @deprecated Use pickers.asset(). */
    pickAsset(request?: {
        readonly title?: string;
        readonly extensions?: readonly string[];
    }): Promise<string | null>;
}
export interface PluginPickersApi {
    note(request?: {
        readonly title?: string;
        readonly query?: string;
    }): Promise<string | null>;
    folder(request?: {
        readonly title?: string;
        readonly query?: string;
    }): Promise<string | null>;
    asset(request?: {
        readonly title?: string;
        readonly query?: string;
        readonly extensions?: readonly string[];
    }): Promise<string | null>;
}
export interface PluginStorageNamespaceApi {
    get(key: string): Promise<JsonValue | null>;
    set(key: string, value: JsonValue): Promise<void>;
    delete(key: string): Promise<void>;
}
export interface PluginStorageApi {
    readonly synced: PluginStorageNamespaceApi;
    readonly local: PluginStorageNamespaceApi;
}
export interface PluginSettingsApi {
    get(key: string): Promise<JsonValue | null>;
    set(key: string, value: JsonValue): Promise<void>;
    delete(key: string): Promise<void>;
    subscribe(callback: (keys: readonly string[]) => void): PluginDisposable;
    open(sectionId?: string): Promise<void>;
}
export interface PluginSecretsApi {
    has(key: string): Promise<boolean>;
    getStorageState(): Promise<PluginSecretStorageStateDto>;
    subscribe(callback: () => void): PluginDisposable;
}
export interface PluginSecretStorageStateDto {
    readonly mode: "synced-encrypted" | "device-local" | "unavailable";
    readonly available: boolean;
    readonly online: boolean;
    readonly migrationPending: boolean;
    readonly syncEnabled: boolean;
}
export interface PluginNetworkRequestDto {
    readonly connection: string;
    readonly path: string;
    readonly method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
    readonly query?: Readonly<Record<string, string | readonly string[]>>;
    readonly headers?: Readonly<Record<string, string>>;
    readonly body?: JsonValue | string | Uint8Array;
    readonly responseType: "json" | "text" | "bytes";
    readonly timeoutMs?: number;
    /** Native callers may cancel directly; isolated runtimes map RPC cancellation to this signal. */
    readonly signal?: AbortSignal;
    readonly credential?: {
        readonly type: "none";
    } | {
        readonly type: "basic";
        readonly usernameSetting: string;
        readonly secret: string;
    } | {
        readonly type: "bearer";
        readonly secret: string;
    } | {
        readonly type: "header";
        readonly name: string;
        readonly secret: string;
    };
}
export interface PluginNetworkResponseDto {
    readonly status: number;
    readonly headers: Readonly<Record<string, string>>;
    readonly body: JsonValue | string | Uint8Array | null;
}
export interface PluginNetworkApi {
    request(request: PluginNetworkRequestDto): Promise<PluginNetworkResponseDto>;
}
export interface PluginJobRunContext {
    /** Host-namespaced `<plugin-id>:<local-job-id>` identity. */
    readonly jobId: string;
    readonly reason: "manual" | "startup" | "interval" | "vault-change" | "asset-change";
    /** Coalesced, bounded trigger reasons represented by this run. */
    readonly reasons: readonly PluginJobRunContext["reason"][];
    /** Aborted on timeout, lifecycle cleanup, suspension, or runner takeover. */
    readonly signal: AbortSignal;
    readonly checkpoint: {
        get(): Promise<JsonValue | null>;
        set(value: JsonValue): Promise<void>;
        delete(): Promise<void>;
    };
}
export interface PluginJobErrorDto {
    readonly code: string;
    readonly message: string;
}
export interface PluginJobRunStatusDto {
    readonly startedAt: string;
    readonly finishedAt: string | null;
    readonly reason: PluginJobRunContext["reason"];
    readonly reasons: readonly PluginJobRunContext["reason"][];
    readonly outcome: "running" | "success" | "failed" | "timeout" | "cancelled";
    readonly error: PluginJobErrorDto | null;
}
export interface PluginJobStatusDto {
    readonly id: string;
    readonly localId: string;
    readonly title: string;
    readonly sideEffecting: boolean;
    readonly running: boolean;
    readonly pending: boolean;
    readonly pendingReasons: readonly PluginJobRunContext["reason"][];
    readonly pausedReason: string | null;
    readonly skippedWhileRunning: number;
    readonly lastSkippedAt: string | null;
    readonly lastRun: PluginJobRunStatusDto | null;
}
export interface PluginJobsApi {
    register(declaration: PluginJobContribution, run: (context: PluginJobRunContext) => void | Promise<void>): PluginDisposable;
    run(id: string): Promise<PluginJobRunStatusDto | null>;
    getStatus(id: string): PluginJobStatusDto;
    listStatuses(): readonly PluginJobStatusDto[];
    subscribe(callback: (statuses: readonly PluginJobStatusDto[]) => void): PluginDisposable;
}
export interface PluginCommandsApi {
    register(declaration: PluginCommandContribution, run: (input: JsonValue | null, context: PluginCommandRunContext) => void | Promise<void>): PluginDisposable;
}
export interface PluginCommandRunContext {
    /** Host-owned runtime generation identity. */
    readonly scopeId: string;
    readonly workspaceContext: PluginWorkspaceContext;
    /** Aborted before the owning plugin scope starts teardown. */
    readonly signal: AbortSignal;
}
export interface NativePluginViewContext {
    readonly instanceId: string;
    readonly initialState: JsonValue | null;
    readonly workspaceContext: PluginWorkspaceContext;
    /** Aborted before the owning leaf or plugin scope starts teardown. */
    readonly signal: AbortSignal;
    openNote(id: string): void;
    openAsset(path: string): void;
    openView(id: string, state?: JsonValue | null): void;
    setTitle(title: string): void;
    pushState(state: JsonValue | null): void;
}
export interface NativePluginViewInstance {
    navigate?(state: JsonValue | null): void | Promise<void>;
    getState?(): JsonValue | null;
    destroy(): void | Promise<void>;
}
export interface NativePluginViewsApi {
    register(declaration: {
        readonly id: string;
        readonly title: string;
        readonly icon?: string;
        create(context: NativePluginViewContext, container: HTMLElement): NativePluginViewInstance | Promise<NativePluginViewInstance>;
    }): PluginDisposable;
}
export interface NativePluginSearchViewMountOptions {
    readonly query?: string;
    readonly configuration: JsonValue;
    readonly resultsReadOnly: boolean;
    readonly configurationReadOnly: boolean;
    readonly allowCreate: boolean;
    readonly allowMutations: boolean;
    /**
     * SearchView never infers note sidecars or plugin storage. Editable
     * configuration is persisted only through the caller callback.
     */
    readonly configurationPersistence: "callback" | "none";
    readonly onConfigurationChange?: (configuration: JsonValue) => void;
    readonly includeBare?: boolean;
    readonly includeAssets?: boolean;
    readonly pageSize?: number;
}
export interface NativePluginSearchViewHandle {
    update(options: {
        readonly query?: string;
        readonly configuration?: JsonValue;
    }): void;
    focus(): void;
    destroy(): void;
}
export interface NativePluginNoteEditorMountOptions {
    readonly noteId: string;
    readonly mode: "edit" | "read";
    readonly features?: {
        readonly properties?: boolean;
        readonly backlinks?: boolean;
        readonly toc?: boolean;
    };
}
export interface NativePluginEditorSelectionDto {
    /** UTF-16 offsets into the Markdown body, never frontmatter. */
    readonly anchor: number;
    readonly head: number;
    readonly direction: "forward" | "backward" | "none";
}
export interface NativePluginNoteEditorHandle {
    focus(): void;
    getSelection(): NativePluginEditorSelectionDto | null;
    revealBlock(blockId: string): boolean;
    destroy(): void;
}
export interface NativePluginMarkdownMountOptions {
    readonly markdown: string;
    readonly sourceNoteId: string;
    readonly interactive: boolean;
}
export interface NativePluginMarkdownHandle {
    update(options: {
        readonly markdown: string;
    }): Promise<boolean>;
    destroy(): void;
}
export interface NativePluginComponentsApi {
    readonly searchView: {
        mount(container: HTMLElement, options: NativePluginSearchViewMountOptions): NativePluginSearchViewHandle;
    };
    readonly noteEditor: {
        mount(container: HTMLElement, options: NativePluginNoteEditorMountOptions): Promise<NativePluginNoteEditorHandle>;
    };
    readonly markdown: {
        mount(container: HTMLElement, options: NativePluginMarkdownMountOptions): NativePluginMarkdownHandle;
    };
}
export interface NativePackageAssetsApi {
    /** Only manifest-declared package assets from this scope's exact snapshot. */
    getUrl(path: string): Promise<PackageAssetUrl>;
}
export interface PluginDeclarativeUiStyleV1 {
    readonly padding?: "none" | "xs" | "sm" | "md" | "lg";
    readonly width?: "auto" | "full";
    readonly align?: "start" | "center" | "end" | "stretch";
    readonly background?: "none" | "surface" | "muted" | "accent";
    readonly border?: "none" | "subtle" | "strong";
    readonly radius?: "none" | "sm" | "md" | "lg";
    readonly text?: "default" | "muted" | "accent" | "success" | "warning" | "error";
    readonly grow?: boolean;
}
interface PluginDeclarativeUiNodeBaseV1 {
    readonly id: string;
    readonly style?: PluginDeclarativeUiStyleV1;
}
export type PluginDeclarativeUiFormFieldV1 = {
    readonly id: string;
    readonly type: "text" | "textarea";
    readonly label: string;
    readonly value?: string;
    readonly required?: boolean;
    readonly disabled?: boolean;
    readonly placeholder?: string;
    readonly maxLength?: number;
} | {
    readonly id: string;
    readonly type: "number";
    readonly label: string;
    readonly value?: number;
    readonly required?: boolean;
    readonly disabled?: boolean;
    readonly min?: number;
    readonly max?: number;
    readonly step?: number;
} | {
    readonly id: string;
    readonly type: "checkbox";
    readonly label: string;
    readonly value?: boolean;
    readonly disabled?: boolean;
} | {
    readonly id: string;
    readonly type: "select";
    readonly label: string;
    readonly value?: string;
    readonly required?: boolean;
    readonly disabled?: boolean;
    readonly options: readonly {
        readonly value: string;
        readonly label: string;
        readonly disabled?: boolean;
    }[];
};
export type PluginDeclarativeUiVectorItemV1 = {
    readonly type: "line";
    readonly x1: number;
    readonly y1: number;
    readonly x2: number;
    readonly y2: number;
    readonly tone: "default" | "accent" | "success" | "warning" | "error" | "muted";
    readonly width?: number;
} | {
    readonly type: "rect";
    readonly x: number;
    readonly y: number;
    readonly width: number;
    readonly height: number;
    readonly tone: "default" | "accent" | "success" | "warning" | "error" | "muted";
    readonly fill?: boolean;
} | {
    readonly type: "circle";
    readonly x: number;
    readonly y: number;
    readonly radius: number;
    readonly tone: "default" | "accent" | "success" | "warning" | "error" | "muted";
    readonly fill?: boolean;
} | {
    readonly type: "polyline";
    readonly points: readonly {
        readonly x: number;
        readonly y: number;
    }[];
    readonly tone: "default" | "accent" | "success" | "warning" | "error" | "muted";
    readonly width?: number;
} | {
    readonly type: "text";
    readonly x: number;
    readonly y: number;
    readonly text: string;
    readonly tone: "default" | "accent" | "success" | "warning" | "error" | "muted";
};
export type PluginDeclarativeUiNode = (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "stack" | "row";
    readonly gap?: "none" | "xs" | "sm" | "md" | "lg";
    readonly children: readonly PluginDeclarativeUiNode[];
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "grid";
    readonly columns: 1 | 2 | 3 | 4 | 6 | 12;
    readonly gap?: "none" | "xs" | "sm" | "md" | "lg";
    readonly children: readonly PluginDeclarativeUiNode[];
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "text";
    readonly text: string;
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "heading";
    readonly text: string;
    readonly level: 1 | 2 | 3 | 4 | 5 | 6;
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "markdown";
    readonly markdown: string;
    readonly sourceNoteId: string;
    readonly interactive: boolean;
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "notice";
    readonly tone: "info" | "success" | "warning" | "error";
    readonly title?: string;
    readonly text: string;
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "button";
    readonly label: string;
    readonly action: string;
    readonly tone?: "default" | "primary" | "danger";
    readonly disabled?: boolean;
    readonly loading?: boolean;
    readonly error?: string;
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "form";
    readonly action: string;
    readonly fields: readonly PluginDeclarativeUiFormFieldV1[];
    readonly submitLabel: string;
    readonly disabled?: boolean;
    readonly loading?: boolean;
    readonly error?: string;
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "property-table";
    readonly caption?: string;
    readonly rows: readonly {
        readonly id: string;
        readonly label: string;
        readonly value: string | number | boolean | null;
        readonly tone?: "default" | "muted" | "success" | "warning" | "error";
    }[];
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "search";
    readonly query: string;
    readonly columns: readonly string[];
    readonly presentation: "list" | "table";
    readonly pageSize?: number;
    readonly includeBare?: boolean;
    readonly includeAssets?: boolean;
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "chart";
    readonly chart: "line" | "bar" | "scatter";
    readonly label: string;
    readonly xLabel?: string;
    readonly yLabel?: string;
    readonly series: readonly {
        readonly id: string;
        readonly label: string;
        readonly tone: "accent" | "success" | "warning" | "error" | "muted";
        readonly points: readonly {
            readonly x: number;
            readonly y: number;
            readonly label?: string;
        }[];
    }[];
}) | (PluginDeclarativeUiNodeBaseV1 & {
    readonly type: "svg" | "canvas";
    readonly label: string;
    readonly width: number;
    readonly height: number;
    readonly items: readonly PluginDeclarativeUiVectorItemV1[];
});
export interface PluginDeclarativeUiViewV1 {
    readonly version: 1;
    readonly root: PluginDeclarativeUiNode;
}
export interface PluginDeclarativeUiActionDto {
    readonly version: 1;
    readonly kind: "action" | "form-submit";
    readonly instanceId: string;
    readonly sourceNodeId: string;
    readonly action: string;
    readonly values: Readonly<Record<string, JsonValue>>;
}
export interface LivePluginUiApi {
    setView(instanceId: string, view: PluginDeclarativeUiViewV1): Promise<void>;
    updateView(instanceId: string, view: PluginDeclarativeUiViewV1): Promise<void>;
    clearView(instanceId: string): Promise<void>;
    onAction(callback: (event: PluginDeclarativeUiActionDto) => void | Promise<void>): PluginDisposable;
}
export interface PluginEventsApi {
    on(type: "activate" | "deactivate", callback: () => void): PluginDisposable;
}
export interface PluginLifecycleApi {
    readonly aborted: boolean;
    onDispose(callback: () => void | Promise<void>): PluginDisposable;
}
export type PluginApiFeatureMap = Readonly<Record<string, boolean>>;
interface PluginApiV1Common<R extends PluginRuntime> {
    readonly version: typeof PLUGIN_API_MAJOR_STRING;
    readonly negotiatedVersion: typeof PLUGIN_API_VERSION;
    readonly mode?: "active";
    readonly runtime: R;
    readonly plugin: PluginIdentity;
    readonly workspaceContext: PluginWorkspaceContext;
    /** Optional additions are detected here or by testing for their namespace. */
    readonly features?: PluginApiFeatureMap;
    readonly commands: PluginCommandsApi;
    readonly workspace: PluginWorkspaceApi;
    readonly dialogs: PluginDialogsApi;
    readonly pickers: PluginPickersApi;
    readonly notes: PluginNotesApi;
    readonly metadata: PluginMetadataApi;
    readonly search: PluginSearchApi;
    readonly assets: PluginAssetsApi;
    readonly settings: PluginSettingsApi;
    readonly secrets: PluginSecretsApi;
    readonly network: PluginNetworkApi;
    readonly jobs: PluginJobsApi;
    readonly storage: PluginStorageApi;
    readonly events: PluginEventsApi;
    readonly lifecycle: PluginLifecycleApi;
}
export interface NativePluginApiV1 extends PluginApiV1Common<"native"> {
    readonly views: NativePluginViewsApi;
    readonly search: NativePluginSearchApi;
    readonly components: NativePluginComponentsApi;
    readonly packageAssets: NativePackageAssetsApi;
    readonly markdownBlocks: NativePluginMarkdownBlocksApi;
    readonly editorExtensions: NativePluginEditorExtensionsApi;
    /** Present when ui.note.action was approved. */
    readonly noteActions?: NativePluginNoteActionsApi;
    /** Present when ui.file.viewer and assets.read were approved. */
    readonly fileViewers?: NativePluginFileViewersApi;
}
export interface SandboxedPagePluginApiV1 extends PluginApiV1Common<"sandboxed-page"> {
    /** Sandboxed pages own only their isolated iframe DOM. */
    readonly views?: never;
    readonly components?: never;
    readonly packageAssets?: never;
    readonly ui?: never;
    readonly markdownBlocks?: never;
}
export interface LiveSandboxedPluginApiV1 extends PluginApiV1Common<"live-sandboxed"> {
    /** Serializable declarative UI only; live plugins never receive a DOM node. */
    readonly ui: LivePluginUiApi;
    readonly views?: never;
    readonly components?: never;
    readonly packageAssets?: never;
    /** Manifest-declared Markdown blocks arrive through the guest lifecycle mount adapter. */
    readonly markdownBlocks?: never;
}
export type PluginApiV1 = NativePluginApiV1 | SandboxedPagePluginApiV1 | LiveSandboxedPluginApiV1;
/**
 * Candidate-update activation receives this narrower API before commit.
 * Runtime guards still reject calls made by untyped JavaScript to omitted
 * side-effect methods. Supported subscriptions remain dormant until commit.
 */
export interface NativePluginPreviewApiV1 {
    readonly version: typeof PLUGIN_API_MAJOR_STRING;
    readonly negotiatedVersion: typeof PLUGIN_API_VERSION;
    readonly mode: "preview";
    readonly runtime: "native";
    readonly plugin: PluginIdentity;
    readonly workspaceContext: PluginWorkspaceContext;
    readonly features?: PluginApiFeatureMap;
    readonly views: NativePluginViewsApi;
    readonly commands: PluginCommandsApi;
    readonly workspace?: Pick<PluginWorkspaceApi, "getTheme" | "onThemeChange">;
    readonly notes?: Pick<PluginNotesApi, "get">;
    readonly metadata?: PluginMetadataApi;
    readonly search?: Pick<NativePluginSearchApi, "query" | "registerPresentation">;
    readonly markdownBlocks: NativePluginMarkdownBlocksApi;
    readonly editorExtensions: NativePluginEditorExtensionsApi;
    readonly noteActions?: NativePluginNoteActionsApi;
    readonly fileViewers?: NativePluginFileViewersApi;
    readonly assets?: Pick<PluginAssetsApi, "list" | "readText" | "readBytes" | "watch">;
    readonly settings?: Pick<PluginSettingsApi, "get" | "subscribe">;
    readonly events?: PluginEventsApi;
    readonly lifecycle: PluginLifecycleApi;
}
export type PluginActivationApiV1 = PluginApiV1 | NativePluginPreviewApiV1;
export {};
