Zum Inhalt
HALOWERK

Agentenwerk

state machine step

Takes a machine definition, the current state, one event and an optional context, and computes a single step. Transitions may carry a guard, which is a declared comparison — field, operator, value — and never an expression: the field is a dotted path into context or payload, so a machine handed in by a stranger cannot execute anything on this server.

POST https://agent.halowerk.com/v1/state-machine-step

Eingaben

Felder des veröffentlichten Eingabeschemas
FeldTypPflichtBeschreibung
machineobjectJaThe automaton definition.
current_statestringJaThe state the machine is in right now.
eventobjectJaThe event to apply.
contextobjectNeinMachine context, addressable in guards as context.<field>. Never modified.
elapsed_in_state_snumberNeinSeconds already spent in current_state. Supplied by you, so the result does not depend on this server clock.
timeout_precedencestringNeinWhich side wins when the deadline is breached and an event transition also matches.
Vollständiges Eingabeschema anzeigen
{
  "type": "object",
  "required": [
    "machine",
    "current_state",
    "event"
  ],
  "additionalProperties": false,
  "properties": {
    "machine": {
      "type": "object",
      "required": [
        "initial",
        "states"
      ],
      "additionalProperties": false,
      "description": "The automaton definition.",
      "properties": {
        "initial": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "description": "Name of the initial state. Must be one of the defined states."
        },
        "states": {
          "type": "array",
          "minItems": 1,
          "maxItems": 200,
          "description": "The states of the machine.",
          "items": {
            "type": "object",
            "required": [
              "name"
            ],
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "State name, unique within the machine."
              },
              "final": {
                "type": "boolean",
                "default": false,
                "description": "If true no event is accepted in this state."
              },
              "timeout_s": {
                "type": "number",
                "minimum": 0,
                "maximum": 31536000,
                "description": "Deadline for this state in seconds."
              },
              "timeout_target": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "State to move to when the deadline is exceeded. Without it a breach is only reported."
              },
              "timeout_actions": {
                "type": "array",
                "maxItems": 20,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "description": "Actions triggered by the deadline transition."
              },
              "on": {
                "type": "array",
                "maxItems": 50,
                "description": "Event-driven transitions out of this state, evaluated in order.",
                "items": {
                  "type": "object",
                  "required": [
                    "event",
                    "target"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "event": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64,
                      "description": "Event name this transition reacts to."
                    },
                    "target": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64,
                      "description": "State to move to."
                    },
                    "actions": {
                      "type": "array",
                      "maxItems": 20,
                      "items": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "description": "Actions triggered by this transition."
                    },
                    "guard": {
                      "type": "object",
                      "required": [
                        "field",
                        "op"
                      ],
                      "additionalProperties": false,
                      "description": "Condition that must hold for this transition to be taken.",
                      "properties": {
                        "field": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200,
                          "description": "Dotted path starting with context. or payload., e.g. context.attempts."
                        },
                        "op": {
                          "type": "string",
                          "enum": [
                            "eq",
                            "ne",
                            "gt",
                            "gte",
                            "lt",
                            "lte",
                            "in",
                            "not_in",
                            "exists",
                            "not_exists"
                          ],
                          "description": "Comparison operator."
                        },
                        "value": {
                          "description": "Right-hand operand. Not used by exists and not_exists; an array for in and not_in."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "current_state": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "The state the machine is in right now."
    },
    "event": {
      "type": "object",
      "required": [
        "name"
      ],
      "additionalProperties": false,
      "description": "The event to apply.",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "description": "Event name."
        },
        "payload": {
          "type": "object",
          "description": "Event data, addressable in guards as payload.<field>."
        }
      }
    },
    "context": {
      "type": "object",
      "description": "Machine context, addressable in guards as context.<field>. Never modified."
    },
    "elapsed_in_state_s": {
      "type": "number",
      "minimum": 0,
      "maximum": 31536000,
      "default": 0,
      "description": "Seconds already spent in current_state. Supplied by you, so the result does not depend on this server clock."
    },
    "timeout_precedence": {
      "type": "string",
      "enum": [
        "timeout",
        "event"
      ],
      "default": "timeout",
      "description": "Which side wins when the deadline is breached and an event transition also matches."
    }
  }
}

Originalschema öffnen

Veröffentlichtes Eingabebeispiel

{
  "machine": {
    "initial": "awaiting_quote",
    "states": [
      {
        "name": "awaiting_quote",
        "timeout_s": 3600,
        "timeout_target": "expired",
        "timeout_actions": [
          "notify_requester"
        ],
        "on": [
          {
            "event": "quote_received",
            "target": "quote_accepted",
            "actions": [
              "book_slot"
            ],
            "guard": {
              "field": "payload.amount_eur",
              "op": "lte",
              "value": 500
            }
          },
          {
            "event": "quote_received",
            "target": "needs_approval",
            "actions": [
              "request_approval"
            ]
          },
          {
            "event": "cancel",
            "target": "cancelled"
          }
        ]
      },
      {
        "name": "quote_accepted",
        "on": [
          {
            "event": "cancel",
            "target": "cancelled"
          }
        ]
      },
      {
        "name": "needs_approval",
        "on": [
          {
            "event": "approved",
            "target": "quote_accepted"
          }
        ]
      },
      {
        "name": "cancelled",
        "final": true
      },
      {
        "name": "expired",
        "final": true
      }
    ]
  },
  "current_state": "awaiting_quote",
  "event": {
    "name": "quote_received",
    "payload": {
      "amount_eur": 420
    }
  },
  "context": {
    "attempts": 1
  },
  "elapsed_in_state_s": 120,
  "timeout_precedence": "timeout"
}

Ergebnis & Dokumentation

Veröffentlichtes Ergebnisschema anzeigen
{
  "$ref": "https://agent.halowerk.com/v1/state-machine-step/schema#/outputSchema"
}

Veröffentlichtes Ergebnisbeispiel öffnen

Maschinenlesbare Dokumentation dieses Hubs

Quelle dieser Seite: der veröffentlichte HALOWERK-Katalog. Stand: 2026-11-01, 15:19 UTC.

Weitere Endpunkte dieses Hubs

Alle Endpunkte dieses Hubs →