/* auto-generated by NAPI-RS */
/* eslint-disable */
export interface AppDiagnosticEntry {
  type: string
  message: string
}

/**
 * Policy inputs for `lintAppHtml`; the TypeScript side is the single source
 * of truth for the CDN allowlist and the injected-SDK surface.
 */
export interface AppHtmlLintConfig {
  /** Bare hostnames `<script src>`/`<link href>` may point at (exact match). */
  resourceHostAllowlist: Array<string>
  /** Top-level members of the injected `window.archestra`. */
  sdkTopLevelMembers: Array<string>
  /** Partitions of `archestra.storage`. */
  sdkStoragePartitions: Array<string>
}

/**
 * Structured lint findings, deduplicated in first-seen document order.
 * Empty when the HTML does not parse (the scan rejects that fail-closed).
 */
export interface AppHtmlLintFindings {
  offAllowlistHosts: Array<string>
  browserStorageApis: Array<string>
  storageMisuse: Array<string>
  unknownTopLevel: Array<string>
}

export interface AppHtmlRejection {
  /**
   * Stable discriminant: `sdk_bootstrap` | `platform_script_src` |
   * `platform_base_css` | `unparseable`.
   */
  kind: string
  offender: string
}

export interface AppHtmlScanResult {
  rejection?: AppHtmlRejection
  warnings: Array<string>
}

/** Clamp the entry count, sanitize each type, and truncate each message. */
export declare function capDiagnosticEntries(entries: Array<AppDiagnosticEntry>, maxEntries: number, maxMessageLen: number): Array<AppDiagnosticEntry>

/**
 * Escape `<`/`>` in untrusted diagnostic text so it cannot break out of the
 * `<app-render-diagnostics>` delimiter block.
 */
export declare function escapeAngleBrackets(text: string): string

/**
 * Render entries as `- [type] message` lines (sanitized, escaped, truncated).
 * Emits only the inner lines; the caller wraps them in the delimiter block.
 */
export declare function formatDiagnosticEntryLines(entries: Array<AppDiagnosticEntry>, maxEntries: number, maxMessageLen: number): string

/**
 * Trusted, platform-built assets the connector embeds directly into the
 * resource when serving a strict foreign host (claude.ai) whose sandbox CSP
 * refuses cross-origin `<script src>`/`<link href>`. Omitted keeps the linked
 * form (Archestra's own render).
 */
export interface InlineAssets {
  /**
   * ext-apps guest bundle as an IIFE publishing the View SDK on
   * `window.__ARCHESTRA_EXT_APPS__`.
   */
  extAppsGlobal: string
  /** The Apps SDK microframework (same bytes served at the SDK path). */
  shim: string
  /** The platform baseline stylesheet (same bytes served at the CSS path). */
  baseCss: string
}

/**
 * Authoring-time lint of app HTML for the `validate_app` tool: hosts the
 * pinned CSP would block, browser storage APIs the sandbox breaks, and
 * `window.archestra` members the injected SDK does not expose. The caller
 * owns the policy inputs and composes the user-facing messages.
 */
export declare function lintAppHtml(html: string, config: AppHtmlLintConfig): AppHtmlLintFindings

/** Union and dedup two already-capped entry lists, capping the total. */
export declare function mergeDiagnosticEntries(existing: Array<AppDiagnosticEntry>, incoming: Array<AppDiagnosticEntry>, maxEntries: number, dedupPrefixLen: number): Array<AppDiagnosticEntry>

/**
 * Inject the platform CSP, baseline stylesheet, per-viewer bootstrap, and Apps
 * SDK into an owned app's HTML. `contextJson` is the caller-serialized
 * per-viewer context (identity + assigned-tool descriptors). `baseOrigin`
 * prefixes the served asset URLs so they resolve in a foreign host's
 * opaque-origin iframe (empty keeps them path-relative); `csp` is the pinned
 * Content-Security-Policy injected as a `<meta>` (empty omits it). When
 * `inlineAssets` is provided the stylesheet and SDK are embedded in the
 * document instead of linked (`baseOrigin` is then unused for assets). See the
 * core crate for the trust boundary on these inputs.
 */
export declare function prepareAppEnvelope(html: string, contextJson: string, baseOrigin: string, csp: string, inlineAssets?: InlineAssets | undefined | null): string

/**
 * Scan authored app HTML for save-time policy violations. Returns a rejection
 * (the first disqualifying construct) plus soft warnings; the caller turns a
 * rejection into the user-facing `ApiError` message.
 */
export declare function scanAppHtml(html: string): AppHtmlScanResult
