AI

ai:action:empty#

Emitted when the selected AI action has no applicable content.

Type: signal.

Payload:

  • action — string — action key
  • mode — string — mode identifier (depends on event)

Example:

app.on('ai:action:empty', ({ action, mode }) => {
  console.log('ai:action:empty', { action, mode });
});

ai:action:empty-response#

Emitted when the AI provider returns an empty response.

Type: signal.

Payload:

  • action — string — action key
  • mode — string — mode identifier (depends on event)

Example:

app.on('ai:action:empty-response', ({ action, mode }) => {
  console.log('ai:action:empty-response', { action, mode });
});

ai:apply#

Emitted when AI suggestions are applied to the document.

Type: signal.

Payload:

  • action — string — action key
  • issues — array of AI review issues
  • applied — number or list of applied changes

Example:

app.on('ai:apply', ({ action, issues, applied }) => {
  console.log('ai:apply', { action, issues, applied });
});

ai:batch:fallback#

Emitted when batched AI processing falls back to sequential mode.

Type: signal.

Payload:

  • error — error that triggered fallback
  • blockCount — number of blocks in the batch
  • batchSize — configured batch size

Example:

app.on('ai:batch:fallback', ({ error, blockCount, batchSize }) => {
  console.warn('AI batch fallback', { error, blockCount, batchSize });
});

ai:before:insert#

Hook emitted before AI-generated content is inserted. Call stop() in the handler to skip insertion for that item.

Type: hook (handler may return a value; call stop() to cancel).

Payload:

  • action — string — action key
  • actionKey — event-specific value
  • configPath — string — config path for nested AI actions
  • prompt — string — AI prompt
  • html — HTML string
  • insertHtml — HTML string to insert
  • blocks — array of block instances
  • selected — whether selection is active

Example:

app.on('ai:before:insert', ({ action, actionKey, configPath, prompt, html, stop }) => {
  if (shouldCancel()) {
    stop();
    return;
  }
  return { action: action, actionKey: actionKey, configPath: configPath, prompt: prompt, html: html, insertHtml: insertHtml, blocks: blocks, selected: selected };
});

ai:before:send#

Hook emitted before an AI request is sent. Return modified request data or call stop() to cancel the request.

Type: hook (handler may return a value; call stop() to cancel).

Payload:

  • action — string — action key
  • configPath — string — config path for nested AI actions
  • prompt — string — AI prompt
  • html — HTML string
  • url — string — request URL
  • init — RequestInit object for the transport layer
  • body — request body object

Example:

app.on('ai:before:send', ({ action, configPath, prompt, html, url, stop }) => {
  if (shouldCancel()) {
    stop();
    return;
  }
  return { action: action, configPath: configPath, prompt: prompt, html: html, url: url, init: init, body: body };
});

ai:complete#

Emitted when an AI request completes successfully.

Type: signal.

Payload:

  • action — string — action key
  • actionKey — event-specific value
  • configPath — string — config path for nested AI actions
  • prompt — string — AI prompt
  • html — HTML string
  • transformed — transformed HTML from AI

Example:

app.on('ai:complete', ({ html }) => {
  console.log(html.length);
});

ai:create#

Hook emitted when an AI session/request is prepared. Return modified fields or call stop() to cancel the request.

Type: hook (handler may return a value; call stop() to cancel).

Payload:

  • action — string — action key
  • actionKey — event-specific value
  • configPath — string — config path for nested AI actions
  • prompt — string — AI prompt
  • html — HTML string
  • requestHtml — HTML sent with the AI request
  • blocks — array of block instances
  • selected — whether selection is active

Example:

app.on('ai:create', ({ action, actionKey, configPath, prompt, html, stop }) => {
  if (shouldCancel()) {
    stop();
    return;
  }
  return { action: action, actionKey: actionKey, configPath: configPath, prompt: prompt, html: html, requestHtml: requestHtml, blocks: blocks, selected: selected };
});

ai:discard#

Emitted when the AI prompt is discarded without applying results.

Type: signal.

Payload:

  • action — string — action key
  • currentAction — event-specific value
  • mode — string — mode identifier (depends on event)
  • currentMode — event-specific value
  • blocks — array of block instances

Example:

app.on('ai:discard', ({ action, currentAction, mode, currentMode, blocks }) => {
  console.log('ai:discard', { action, currentAction, mode, currentMode, blocks });
});

ai:error#

Emitted when an error occurs in the ai flow.

Type: signal.

Payload:

  • error — error value
  • action — string — action key

Example:

app.on('ai:error', ({ error, err, action }) => {
  console.log('ai:error', { error, err, action });
});

ai:image:error#

Emitted during the AI image flow step image:error.

Type: signal.

Payload:

  • error — error value

Example:

app.on('ai:image:error', ({ error, err }) => {
  console.log('ai:image:error', { error, err });
});

ai:image:before#

Hook emitted before an AI image request is sent. Return modified url, body, or headers, or call stop() to cancel the request.

Type: hook (handler may return a value; call stop() to cancel).

Payload:

  • url — string — request URL
  • body — request body object
  • headers — request headers object

Example:

app.on('ai:image:before', ({ url, body, headers, stop }) => {
  if (shouldCancel()) {
    stop();
    return;
  }
  return { url: url, body: body, headers: headers };
});

ai:image:request#

Emitted before an AI image request is sent.

Type: signal.

Payload:

  • url — string — request URL
  • finalUrl — resolved request URL
  • body — request body object
  • finalBody — resolved request body

Example:

app.on('ai:image:request', ({ url, finalUrl, body, finalBody }) => {
  console.log('ai:image:request', { url, finalUrl, body, finalBody });
});

ai:image:response#

Emitted when an AI image response is received.

Type: signal.

Payload: none.

Example:

app.on('ai:image:response', () => {
  // react to the signal
});

ai:insert#

Emitted when AI-generated content is inserted into the document.

Type: signal.

Payload:

  • blocks — array of block instances
  • inserted — event-specific value
  • html — HTML string
  • finalHtml — event-specific value
  • action — string — action key
  • issue — AI review issue object
  • actionKey — event-specific value
  • configPath — string — config path for nested AI actions
  • prompt — string — AI prompt
  • newBlocks — event-specific value
  • insert — insert operation result
  • insertRes — event-specific value

Example:

app.on('ai:insert', ({ html }) => {
  console.log(html.length);
});

ai:job:cancelled#

Emitted when an async AI job is cancelled.

Type: signal.

Payload:

  • jobId — string — async job id

Example:

app.on('ai:job:cancelled', ({ jobId }) => {
  console.log('ai:job:cancelled', { jobId });
});

ai:job:created#

Emitted when an async AI job is created.

Type: signal.

Payload:

  • jobId — string — async job id
  • pollUrl — string — job poll URL
  • createUrl — string — job create URL

Example:

app.on('ai:job:created', ({ jobId, pollUrl, createUrl }) => {
  console.log('ai:job:created', { jobId, pollUrl, createUrl });
});

ai:job:poll#

Emitted when an async AI job is polled.

Type: signal.

Payload:

  • jobId — string — async job id
  • pollCount — number — poll attempt count
  • status — string — job or item status

Example:

app.on('ai:job:poll', ({ jobId, pollCount, status }) => {
  console.log('ai:job:poll', { jobId, pollCount, status });
});

ai:prompt:close#

Emitted when the AI prompt panel closes.

Type: signal.

Payload: none.

Example:

app.on('ai:prompt:close', () => {
  // react to the signal
});

ai:prompt:empty#

Emitted when the user submits an empty AI prompt.

Type: signal.

Payload: none.

Example:

app.on('ai:prompt:empty', () => {
  // react to the signal
});

ai:prompt:open#

Emitted when the AI prompt panel opens.

Type: signal.

Payload:

  • blocks — array of block instances
  • targetBlocks — event-specific value
  • action — string — action key
  • currentAction — event-specific value
  • mode — string — mode identifier (depends on event)
  • currentMode — event-specific value

Example:

app.on('ai:prompt:open', ({ blocks, targetBlocks, action, currentAction, mode }) => {
  console.log('ai:prompt:open', { blocks, targetBlocks, action, currentAction, mode });
});

ai:report:empty#

Emitted when an AI report has no content.

Type: signal.

Payload: none.

Example:

app.on('ai:report:empty', () => {
  // react to the signal
});

ai:report:open#

Emitted when an AI report view is opened.

Type: signal.

Payload:

  • action — string — action key
  • raw — raw AI response payload
  • title — string — title text
  • key — string — key name

Example:

app.on('ai:report:open', ({ action, raw, title, key }) => {
  console.log('ai:report:open', { action, raw, title, key });
});

ai:review:accept#

Emitted when AI review suggestions are accepted.

Type: signal.

Payload:

  • action — string — action key
  • issue — AI review issue object
  • issues — array of AI review issues

Example:

app.on('ai:review:accept', ({ action, issue, issues }) => {
  console.log('ai:review:accept', { action, issue, issues });
});

ai:review:close#

Emitted when the AI review panel closes.

Type: signal.

Payload:

  • action — string — action key
  • wasAction — action key before the panel closed

Example:

app.on('ai:review:close', ({ action, wasAction }) => {
  console.log('ai:review:close', { action, wasAction });
});

ai:review:empty#

Emitted when AI review has no issues to show.

Type: signal.

Payload: none.

Example:

app.on('ai:review:empty', () => {
  // react to the signal
});

ai:review:open#

Emitted when the AI review panel opens with issues to inspect.

Type: signal.

Payload:

  • action — string — action key
  • issues — array of AI review issues

Example:

app.on('ai:review:open', ({ action, issues }) => {
  console.log('ai:review:open', { action, issues });
});

ai:review:reject#

Emitted when AI review suggestions are rejected.

Type: signal.

Payload:

  • action — string — action key
  • issue — AI review issue object
  • issues — array of AI review issues

Example:

app.on('ai:review:reject', ({ action, issue, issues }) => {
  console.log('ai:review:reject', { action, issue, issues });
});

ai:send#

Emitted when an AI text request is sent to the transport layer.

Type: signal.

Payload:

  • url — string — request URL
  • finalUrl — resolved request URL
  • body — request body object
  • finalBody — resolved request body
  • batch — event-specific value
  • batchMeta — batch request metadata

Example:

app.on('ai:send', ({ url, finalUrl, body, finalBody, batch }) => {
  console.log('ai:send', { url, finalUrl, body, finalBody, batch });
});

ai:stop#

Emitted when an in-flight AI request is stopped by the user.

Type: signal.

Payload:

  • source — string — source identifier (e.g. clipboard, html)
  • action — string — action key
  • currentAction — event-specific value
  • mode — string — mode identifier (depends on event)
  • currentMode — event-specific value

Example:

app.on('ai:stop', ({ source, action, currentAction, mode, currentMode }) => {
  console.log('ai:stop', { source, action, currentAction, mode, currentMode });
});