# Execute Sommatic App

> Solicita a un usuario que interactúe con la UI de una Sommatic AI App concreta.

Source: https://docs.sommatic.ai/es/nodes/sommatic.app.execute/

- Slug: `sommatic.app.execute`
- Familia: Human in the loop
- Versión: 1.0.0
- Estado: Parcial. Crea la interacción con la app en el backend y luego devuelve `__signal: 'SUSPEND'`, que el motor de ejecución nunca procesa: el workflow no espera la salida de la app y continúa por el puerto predeterminado.
- Ejecución: async

Solicita a un usuario que interactúe con la UI de una Sommatic AI App concreta.

## Configuración

- `app_identifier` (string, obligatorio): Slug o ID de la app o micro-frontend
- `assignee` (string, opcional)
- `timeout_ms` (integer, opcional): Por defecto: `3600000`.
- `configuration` (object, opcional): Props o contexto que se pasan a la app de UI

Su configuración muestra los ajustes de ejecución compartidos, pero este nodo aún no aplica reintentos (`retryOnFail`, `maxTries`). Ningún nodo aplica `continueOnFail`.

## Puertos de salida

- `completed` (por defecto): Interacción completada
- `timeout`: La interacción venció
- `error`: Error

## Contrato de entrada

- `app_identifier` (string, opcional)
- `assignee` (string, opcional)
- `timeout_ms` (integer, opcional)
- `configuration` (object, opcional)

## Contrato de salida

- `result` (object, opcional)
- `status` (string, opcional)

## En expresiones

Lo que un nodo posterior puede leer de la salida de este nodo con `$("Execute Sommatic App").item.json.<ruta>`, tal como lo sugiere el editor de workflows en Previous Nodes (el contrato de salida).

- `$("Execute Sommatic App").item.json.result` (object)
- `$("Execute Sommatic App").item.json.status` (string)


## Cómo funciona

Parcial. Pide al backend crear una interacción con una app y devuelve una señal de suspensión que el motor no procesa: la ejecución no espera a la app ni sigue `completed` ni `timeout`.

1. Resuelve la configuración y la combina sobre el payload de entrada (gana la configuración).
2. Lanza un error si falta `app_identifier`: la ejecución falla, salvo que un ámbito `flow.try` lo capture.
3. Envía `{ type: "app_execution", app_identifier, configuration, assignee, expires_in_ms: timeout_ms }` al endpoint de interacciones HITL del backend; un fallo HTTP se vuelve a lanzar.
4. Devuelve `{ __signal: "SUSPEND", __metadata: { type: "sommatic_app_interaction", id, resume_on: ["completed", "timeout"] } }`.
5. El sobre no tiene puerto, así que el motor lo envía a `out`, que este nodo no declara: las aristas de `completed` o `timeout` nunca se siguen, la rama termina y la ejecución se completa sin esperar.

## En un workflow

### Nodo

```json
{
  "node_id": "node-open-intake",
  "label": "Open intake app",
  "operator_slug": "sommatic.app.execute",
  "operator_version": "1.0.0",
  "config": {
    "app_identifier": "sommatic-structured-intake",
    "assignee": "operator@example.com",
    "timeout_ms": 3600000,
    "configuration": {
      "case_id": "{{ $json.case_id }}"
    }
  }
}
```

### Envelope

```json
{
  "ok": true,
  "port": "out",
  "__signal": "SUSPEND",
  "__metadata": {
    "type": "sommatic_app_interaction",
    "id": "<interaction_id>",
    "resume_on": [
      "completed",
      "timeout"
    ]
  }
}
```

## Puertos de salida (comportamiento en el código)

### `completed`

Nunca se emite.

### `timeout`

Nunca se emite.

### `error`

Nunca se emite: los fallos se lanzan como excepción y hacen fallar la ejecución.

## Comportamiento en el código

- `timeout_ms`: Solo se envía al backend como `expires_in_ms`; el orquestador no lo aplica.

## Errores

| Mensaje | Puerto | Causa y solución |
| --- | --- | --- |
| `Missing 'app_identifier'` | `error` | Se lanza como excepción. La ejecución falla con `Node <node_id> (sommatic.app.execute) failed: Missing 'app_identifier'`, o va al nodo catch de un `flow.try` que la contenga. |
| `Request failed with status code <status>` | `error` | Se lanza cuando el backend rechaza la solicitud de interacción; mismo efecto que arriba. |

## Notas y límites

- Al momento de la revisión, el backend de Sommatic AI no exponía ningún manejador para esta solicitud de interacción, así que se espera que la llamada falle y, con ella, la ejecución. La operación de reanudación del orquestador solo acepta `stoneos.industry.apply`.
- Para un paso humano hoy, usa `human.task.create` (tarea que no bloquea la ejecución) o `sommatic.app.handoff` (entrega final a una app).
- El sobre del ejemplo muestra `ok` y `port` como los interpreta el motor; el worker solo devuelve `__signal` y `__metadata`.


## Contratos (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "sommatic.app.execute",
  "name": "Execute Sommatic App",
  "category": "hitl",
  "version": "1.0.0",
  "description": "Requests a user to interact with a specific Sommatic AI App UI.",
  "capabilities": [
    "ui",
    "interactive",
    "human"
  ],
  "config_schema": {
    "type": "object",
    "required": [
      "app_identifier"
    ],
    "properties": {
      "app_identifier": {
        "type": "string",
        "title": "App Identifier",
        "description": "Slug or ID of the frontend app/micro-frontend"
      },
      "assignee": {
        "type": "string",
        "title": "Assignee",
        "ui_widget": "user_picker"
      },
      "timeout_ms": {
        "type": "integer",
        "default": 3600000
      },
      "configuration": {
        "type": "object",
        "title": "App Configuration",
        "description": "Props or context passed to the UI app"
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "app_identifier": {
        "type": "string"
      },
      "assignee": {
        "type": "string"
      },
      "timeout_ms": {
        "type": "integer"
      },
      "configuration": {
        "type": "object"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "object"
      },
      "status": {
        "type": "string"
      }
    }
  },
  "ports": [
    {
      "port_id": "completed",
      "label": "Completed",
      "is_default": true,
      "description": "Interaction completed"
    },
    {
      "port_id": "timeout",
      "label": "Timeout",
      "description": "Interaction expired"
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "async",
  "tags": [
    "ui",
    "interactive"
  ],
  "is_stateful": true,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "required": [
    "app_identifier"
  ],
  "properties": {
    "app_identifier": {
      "type": "string",
      "title": "App Identifier",
      "description": "Slug or ID of the frontend app/micro-frontend"
    },
    "assignee": {
      "type": "string",
      "title": "Assignee",
      "ui_widget": "user_picker"
    },
    "timeout_ms": {
      "type": "integer",
      "default": 3600000
    },
    "configuration": {
      "type": "object",
      "title": "App Configuration",
      "description": "Props or context passed to the UI app"
    },
    "execution": {
      "type": "object",
      "title": "Execution Settings",
      "properties": {
        "alwaysOutputData": {
          "type": "boolean",
          "title": "Always Output Data",
          "description": "Always output data, even on error (if configured).",
          "default": false
        },
        "retryOnFail": {
          "type": "boolean",
          "title": "Retry On Fail",
          "description": "Retry the execution if it fails.",
          "default": false
        },
        "maxTries": {
          "type": "integer",
          "title": "Max Retries",
          "description": "Number of retries.",
          "default": 3,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "waitBetweenTries": {
          "type": "integer",
          "title": "Wait Between Retries (ms)",
          "default": 1000,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "continueOnFail": {
          "type": "boolean",
          "title": "Continue On Fail",
          "description": "Do not crash workflow on error.",
          "default": false
        },
        "timeout_ms": {
          "type": "integer",
          "title": "Timeout (ms)",
          "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
          "default": 300000
        }
      }
    }
  }
}
```

### input_contract_schema

```json
{
  "type": "object",
  "properties": {
    "app_identifier": {
      "type": "string"
    },
    "assignee": {
      "type": "string"
    },
    "timeout_ms": {
      "type": "integer"
    },
    "configuration": {
      "type": "object"
    }
  }
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "result": {
      "type": "object"
    },
    "status": {
      "type": "string"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "completed",
    "label": "Completed",
    "is_default": true,
    "description": "Interaction completed"
  },
  {
    "port_id": "timeout",
    "label": "Timeout",
    "description": "Interaction expired"
  },
  {
    "port_id": "error",
    "label": "Error"
  }
]
```
