unlayer-types 1.515.0 → 1.519.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/embed.d.ts +204 -5
  2. package/package.json +1 -1
package/embed.d.ts CHANGED
@@ -2102,10 +2102,10 @@ declare module "packages/editor/src/engine/config/features" {
2102
2102
  * Model identifier for the AI copilot.
2103
2103
  *
2104
2104
  * Accepts either:
2105
- * - a bare model id (e.g. `"gpt-5.6-luna"`, `"claude-opus-5"`), where the
2105
+ * - a bare model id (e.g. `"gpt-5.6-luna"`, `"claude-opus-5-5"`), where the
2106
2106
  * server infers the provider from the id, or
2107
2107
  * - a `"<provider>/<modelId>"` pair (e.g. `"openai/gpt-5.6-luna"`,
2108
- * `"anthropic/claude-opus-5"`) — preferred when the model id is
2108
+ * `"anthropic/claude-opus-5-5"`) — preferred when the model id is
2109
2109
  * ambiguous across providers.
2110
2110
  *
2111
2111
  * Typed as a template literal union so editors autocomplete the known
@@ -2300,7 +2300,7 @@ declare module "packages/editor/src/engine/config/features" {
2300
2300
  * Preferred AI model for the assistant. Accepts:
2301
2301
  *
2302
2302
  * - a `"<provider>/<modelId>"` pair (e.g. `"openai/gpt-5.6-luna"`,
2303
- * `"anthropic/claude-opus-5"`) — pins both provider and model,
2303
+ * `"anthropic/claude-opus-5-5"`) — pins both provider and model,
2304
2304
  * unambiguous;
2305
2305
  * - a bare model id (e.g. `"gpt-5.6-luna"`);
2306
2306
  * - a provider name (e.g. `"openai"`, `"anthropic"`) — selects the
@@ -2537,7 +2537,7 @@ declare module "packages/editor/src/engine/config/features" {
2537
2537
  * Preferred AI model for the assistant. Accepts:
2538
2538
  *
2539
2539
  * - a `"<provider>/<modelId>"` pair (e.g. `"openai/gpt-5.6-luna"`,
2540
- * `"anthropic/claude-opus-5"`) — pins both provider and model,
2540
+ * `"anthropic/claude-opus-5-5"`) — pins both provider and model,
2541
2541
  * unambiguous;
2542
2542
  * - a bare model id (e.g. `"gpt-5.6-luna"`);
2543
2543
  * - a provider name (e.g. `"openai"`, `"anthropic"`) — selects the
@@ -2874,6 +2874,15 @@ declare module "packages/editor/src/embed/Config" {
2874
2874
  defaultErrors: Audit[];
2875
2875
  }) => Audit[] | Promise<Audit[]>;
2876
2876
  tabs?: Tabs;
2877
+ /**
2878
+ * Lets AI agents operating the page (browser agents, automation scripts)
2879
+ * find this editor through `unlayer.agent` and edit its design JSON instead
2880
+ * of driving the drag-and-drop UI. Once the editor confirms it supports
2881
+ * this (older pinned or stable versions don't), appends a short pointer to
2882
+ * the editor iframe's accessible name; nothing changes on screen. Set to
2883
+ * `false` to leave this editor out of `unlayer.agent`. Defaults to `true`.
2884
+ */
2885
+ agentApi?: boolean;
2877
2886
  }
2878
2887
  export interface SaveDesignOptions {
2879
2888
  }
@@ -2887,6 +2896,12 @@ declare module "packages/editor/src/embed/Config" {
2887
2896
  live?: boolean;
2888
2897
  mergeTags?: MergeTagsValues;
2889
2898
  minify?: boolean;
2899
+ /**
2900
+ * Include classic Outlook for Windows and legacy IE conditional markup in
2901
+ * email HTML. Defaults to true. False also removes custom HTML conditionals;
2902
+ * AMP HTML and other display modes are unchanged.
2903
+ */
2904
+ outlookSupport?: boolean;
2890
2905
  popupId?: string;
2891
2906
  title?: string;
2892
2907
  validateAmp?: boolean;
@@ -2908,7 +2923,7 @@ declare module "packages/editor/src/embed/Config" {
2908
2923
  }
2909
2924
  export interface ExportLiveHtmlResult<TDisplayMode extends DisplayMode | undefined = undefined> extends ExportHtmlResult<TDisplayMode> {
2910
2925
  }
2911
- export interface ExportPlainTextOptions extends Omit<ExportHtmlOptions, 'cleanup' | 'minify'> {
2926
+ export interface ExportPlainTextOptions extends Omit<ExportHtmlOptions, 'cleanup' | 'minify' | 'outlookSupport'> {
2912
2927
  ignorePreheader?: boolean;
2913
2928
  }
2914
2929
  export interface ExportPlainTextResult<TDisplayMode extends DisplayMode | undefined = undefined> {
@@ -2990,6 +3005,11 @@ declare module "packages/editor/src/embed/Frame" {
2990
3005
  */
2991
3006
  iframeTextColor?: string;
2992
3007
  }
3008
+ /** What this frame's editor build says it supports. */
3009
+ export interface FrameCapabilities {
3010
+ /** Answers `agent:*` messages (`unlayer.agent`). */
3011
+ agentApi: boolean;
3012
+ }
2993
3013
  export class Frame {
2994
3014
  id: number;
2995
3015
  ready: boolean;
@@ -2999,9 +3019,19 @@ declare module "packages/editor/src/embed/Frame" {
2999
3019
  callbacks: {
3000
3020
  [key: number]: ((...args: any[]) => any) | undefined;
3001
3021
  };
3022
+ /** Null until the editor announces itself (or the iframe finishes loading). */
3023
+ capabilities: FrameCapabilities | null;
3024
+ private capabilityListeners;
3002
3025
  constructor(src: string, options?: FrameOptions);
3003
3026
  createIframe(src: string, { iframeBackgroundColor, iframeTextColor }?: FrameOptions): HTMLIFrameElement;
3004
3027
  destroy: () => void;
3028
+ /**
3029
+ * Calls `listener` with the editor's capabilities once they are known, and
3030
+ * again if they improve: an `unlayer:ready` that arrives after the load
3031
+ * fallback still turns a capability on. Capabilities never turn off.
3032
+ */
3033
+ onCapabilities(listener: (capabilities: FrameCapabilities) => void): void;
3034
+ private setCapabilities;
3005
3035
  appendTo(el: Element): void;
3006
3036
  onWindowMessage: (event: MessageEvent<any>) => void;
3007
3037
  postMessage(action: string, message: Message): void;
@@ -4168,6 +4198,165 @@ declare module "packages/editor/src/embed/iframeBackground" {
4168
4198
  export const getIframeBackgroundColor: (theme: unknown) => string | undefined;
4169
4199
  export const getIframeTextColor: (theme: unknown) => string | undefined;
4170
4200
  }
4201
+ declare module "packages/editor/src/embed/agent/agentHint" {
4202
+ export const EDITOR_NAME = "Design editor";
4203
+ export const AGENT_HINT = "AI agents: skip the UI, call unlayer.agent.describe() or unlayer_describe_editor";
4204
+ /**
4205
+ * Names the editor iframe and, when this editor answers agent calls, appends
4206
+ * the pointer to `unlayer.agent`. The `title` attribute is not rendered as a
4207
+ * tooltip on iframes, so nothing changes on screen. The host page script owns
4208
+ * these strings, so they are not localized. `EDITOR_NAME` has no vendor
4209
+ * branding; the pointer does name `unlayer`, because that is the global
4210
+ * (and the site tool prefix) agents have to call.
4211
+ */
4212
+ export function applyAgentHint(iframe: HTMLIFrameElement | undefined, { agentApi }: {
4213
+ agentApi: boolean;
4214
+ }): void;
4215
+ }
4216
+ declare module "packages/editor/src/embed/agent/registry" {
4217
+ import type { Frame } from "packages/editor/src/embed/Frame";
4218
+ /** The slice of `Editor` the agent API needs, kept narrow to avoid a cycle. */
4219
+ export interface AgentEditor {
4220
+ frame: Frame | null;
4221
+ readonly version: string | undefined;
4222
+ readonly agentContainerId: string | null;
4223
+ }
4224
+ /** The editor's iframe hasn't said yet whether it supports the agent API. */
4225
+ export function markAgentEditorPending(editor: AgentEditor): void;
4226
+ /** The editor's iframe answers agent calls. */
4227
+ export function registerAgentEditor(editor: AgentEditor): void;
4228
+ export function unregisterAgentEditor(editor: AgentEditor): void;
4229
+ export function getAgentEditors(): AgentEditor[];
4230
+ /**
4231
+ * Resolves once no editor on the page is still waiting for its iframe, or
4232
+ * after `timeoutMs`. Lets an agent that calls right after page load reach an
4233
+ * editor that is still booting instead of being told there is none.
4234
+ */
4235
+ export function whenAgentEditorsKnown(timeoutMs: number): Promise<void>;
4236
+ export function getAgentRevision(editor: AgentEditor): number | undefined;
4237
+ export function setAgentRevision(editor: AgentEditor, revision: unknown): void;
4238
+ }
4239
+ declare module "packages/editor/src/embed/agent/AgentApi" {
4240
+ import type { ExportHtmlOptions, ExportHtmlResult } from "packages/editor/src/embed/Config";
4241
+ import type { JSONTemplate } from "packages/editor/src/state/types/types";
4242
+ export interface AgentTarget {
4243
+ /** Index into `describe().editors`. Defaults to the first editor. */
4244
+ editor?: number;
4245
+ }
4246
+ export interface AgentDesignIssue {
4247
+ path: string;
4248
+ message: string;
4249
+ code: string;
4250
+ }
4251
+ export interface AgentLoadDesignResult {
4252
+ /** True when the design passed validation and was loaded. */
4253
+ ok: boolean;
4254
+ loaded: boolean;
4255
+ errors: AgentDesignIssue[];
4256
+ errorCount: number;
4257
+ /**
4258
+ * Ids of elements the template protects (locked, or not editable,
4259
+ * deletable, or movable) that the design tried to change. They keep their
4260
+ * current content; everything else was applied.
4261
+ */
4262
+ protectedElements?: string[];
4263
+ /** The editor's quality checks on the loaded design; null if they couldn't run. */
4264
+ audit?: {
4265
+ status: 'PASS' | 'FAIL';
4266
+ issues: Array<{
4267
+ severity: 'ERROR' | 'WARNING';
4268
+ title: string;
4269
+ description: string;
4270
+ elementId?: string;
4271
+ }>;
4272
+ issueCount: number;
4273
+ } | null;
4274
+ }
4275
+ export interface AgentEditorSummary {
4276
+ index: number;
4277
+ containerId: string | null;
4278
+ version: string | undefined;
4279
+ }
4280
+ export interface AgentDescription {
4281
+ /** Markdown instructions for the agent. Read this first. */
4282
+ guide: string;
4283
+ editors: AgentEditorSummary[];
4284
+ editor: number;
4285
+ displayMode: string;
4286
+ designMode: string | null;
4287
+ schemaVersion: number;
4288
+ contentTypes: string[];
4289
+ customTools: Array<Record<string, unknown> & {
4290
+ slug: string;
4291
+ }>;
4292
+ /** Merge tags to personalize text with, written exactly as `value`. */
4293
+ mergeTags: Array<{
4294
+ name: string;
4295
+ value: string;
4296
+ }>;
4297
+ fonts: Array<{
4298
+ label: string;
4299
+ value: string;
4300
+ }>;
4301
+ }
4302
+ /**
4303
+ * `unlayer.agent`: a promise-based surface for AI agents operating the page.
4304
+ *
4305
+ * Agents fail at the drag-and-drop UI but write good design JSON once they
4306
+ * know `loadDesign` exists. This gives them one discoverable entry point,
4307
+ * `describe()`, that returns instructions plus this editor's real
4308
+ * capabilities (content types, custom tools, fonts), and a `loadDesign` that
4309
+ * reports schema errors instead of silently loading a broken design.
4310
+ */
4311
+ export interface AgentApi {
4312
+ /** Instructions and this editor's capabilities. Call this first. */
4313
+ describe(target?: AgentTarget): Promise<AgentDescription>;
4314
+ /** Full JSON Schema of the design this editor accepts, custom tools included. */
4315
+ schema(target?: AgentTarget): Promise<Record<string, unknown>>;
4316
+ getDesign(target?: AgentTarget): Promise<JSONTemplate>;
4317
+ /**
4318
+ * Validates, then loads. On `{ ok: false, loaded: false }` nothing changed;
4319
+ * fix `errors` and retry.
4320
+ */
4321
+ loadDesign(design: JSONTemplate, options?: AgentTarget): Promise<AgentLoadDesignResult>;
4322
+ exportHtml(options?: AgentTarget & ExportHtmlOptions): Promise<ExportHtmlResult>;
4323
+ /**
4324
+ * Opens the editor's preview at a device size, so the agent can check its
4325
+ * work in a screenshot; `null` closes it and puts the canvas back on the
4326
+ * device it was on. Resolves once the change has rendered.
4327
+ */
4328
+ preview(device: AgentPreviewDevice | null, target?: AgentTarget): Promise<void>;
4329
+ }
4330
+ export type AgentPreviewDevice = 'desktop' | 'tablet' | 'mobile';
4331
+ export const agentApi: AgentApi;
4332
+ }
4333
+ declare module "packages/editor/src/embed/agent/agentSiteTools" {
4334
+ /**
4335
+ * Registers `unlayer.agent` as WebMCP site tools (`document.modelContext`).
4336
+ *
4337
+ * Some agents can't run JavaScript in the page at all — ChatGPT's agent mode
4338
+ * among them — so they can never call `unlayer.agent`, however clearly the
4339
+ * hint points to it. They do list the tools a page registers, and call those
4340
+ * instead of clicking through the UI. Each tool is a thin wrapper over the
4341
+ * matching `unlayer.agent` call, so both paths behave identically.
4342
+ *
4343
+ * Registered from the host page (embed.js), not the editor iframe: tools in a
4344
+ * cross-origin iframe need an `allow="tools"` permission the embedder would
4345
+ * have to grant.
4346
+ */
4347
+ interface SiteTool {
4348
+ name: string;
4349
+ description: string;
4350
+ inputSchema: Record<string, unknown>;
4351
+ annotations?: Record<string, boolean>;
4352
+ execute: (input: Record<string, any>) => Promise<unknown>;
4353
+ }
4354
+ export function buildAgentSiteTools(): SiteTool[];
4355
+ /** Registers the tools once, when the first agent-enabled editor appears. */
4356
+ export function ensureAgentSiteTools(): void;
4357
+ /** Unregisters the tools once no agent-enabled editor is left. */
4358
+ export function releaseAgentSiteTools(): void;
4359
+ }
4171
4360
  declare module "packages/editor/src/embed/Editor" {
4172
4361
  import { Frame } from "packages/editor/src/embed/Frame";
4173
4362
  import type { Config, ExportFromApiResult, ExportHtmlOptions, ExportHtmlResult, ExportPlainTextResult, ExportImageFromApiOptions, ExportLiveHtmlOptions, ExportPdfFromApiOptions, ExportPlainTextOptions, ExportZipFromApiOptions, SaveDesignOptions, ExportLiveHtmlResult } from "packages/editor/src/embed/Config";
@@ -4191,6 +4380,9 @@ declare module "packages/editor/src/embed/Editor" {
4191
4380
  frame: Frame | null;
4192
4381
  constructor(config?: Config);
4193
4382
  init(config?: Config): void;
4383
+ /** Container element id, so agents can tell several editors apart. */
4384
+ get agentContainerId(): string | null;
4385
+ private initAgentApi;
4194
4386
  private captureTargetElement;
4195
4387
  destroy(): void;
4196
4388
  versions: {
@@ -4319,9 +4511,16 @@ declare module "packages/editor/src/embed/Editor" {
4319
4511
  }
4320
4512
  declare module "packages/editor/src/embed/index" {
4321
4513
  import { Editor } from "packages/editor/src/embed/Editor";
4514
+ import { type AgentApi } from "packages/editor/src/embed/agent/AgentApi";
4322
4515
  import type { Config } from "packages/editor/src/embed/Config";
4323
4516
  import type { DisplayMode } from "packages/editor/src/state/types/types";
4324
4517
  class Embed extends Editor {
4518
+ /**
4519
+ * Entry point for AI agents operating the page: start with
4520
+ * `await unlayer.agent.describe()`. Covers every editor on the page,
4521
+ * including `createEditor()` instances.
4522
+ */
4523
+ agent: AgentApi;
4325
4524
  createEditor<TDisplayMode extends DisplayMode | undefined = undefined>(config: Config): Editor<TDisplayMode>;
4326
4525
  }
4327
4526
  const _default: Embed;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "unlayer-types",
3
- "version": "1.515.0",
3
+ "version": "1.519.0",
4
4
  "license": "MIT"
5
5
  }