{
  "$defs": {
    "ActionNode": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "label": {
          "maxLength": 200,
          "minLength": 1,
          "title": "Label",
          "type": "string"
        },
        "type": {
          "const": "action",
          "title": "Type",
          "type": "string"
        },
        "binding_id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Binding Id",
          "type": "string"
        },
        "hold_line": {
          "anyOf": [
            {
              "maxLength": 28,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "A short fixed sentence the caller hears while this step's tool runs, such as \"One moment please.\" It starts when the tool starts, in the agent's voice, and the agent's next words wait until it has been said. At most about 2.5 seconds of speech: up to 28 characters, about 25 in Hebrew or Arabic, fewer in Chinese, Japanese or Korean, and a digit counts as about three. Fixed text: no {{...}} references. Not on a transfer step, which has its own announcement.",
          "title": "Hold Line"
        }
      },
      "required": [
        "id",
        "label",
        "type",
        "binding_id"
      ],
      "title": "ActionNode",
      "type": "object"
    },
    "AfterTrigger": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "event": {
          "enum": [
            "call.answered",
            "call.ended",
            "call.failed",
            "call.no_answer",
            "ai_session.ended",
            "transfer.accepted",
            "transfer.answered",
            "transfer.failed",
            "transcript.ready",
            "analysis.ready",
            "recording.ready",
            "lead.ready",
            "billing.ready",
            "any_end",
            "request.failed"
          ],
          "title": "Event",
          "type": "string"
        },
        "steps": {
          "items": {
            "$ref": "#/$defs/SequenceStep"
          },
          "maxItems": 256,
          "title": "Steps",
          "type": "array"
        },
        "when": {
          "anyOf": [
            {
              "discriminator": {
                "mapping": {
                  "all_of": "#/$defs/AllOf",
                  "any_of": "#/$defs/AnyOf",
                  "compare": "#/$defs/Comparison",
                  "not": "#/$defs/NotCondition"
                },
                "propertyName": "kind"
              },
              "oneOf": [
                {
                  "$ref": "#/$defs/Comparison"
                },
                {
                  "$ref": "#/$defs/AllOf"
                },
                {
                  "$ref": "#/$defs/AnyOf"
                },
                {
                  "$ref": "#/$defs/NotCondition"
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional. An \"Only if\" on this follow-up: the steps run only when the condition holds for the call. Reads the call itself ({\"kind\": \"call\", \"path\": \"/status\"}) and fixed values, and only the facts this trigger's event guarantees: how the call ended (result, who ended it, duration) on an ending, the disposition and collected fields on analysis.ready, direction and channel on any event. When it does not hold, every step is recorded as skipped (guard_false) and the follow-up counts as done.",
          "title": "When"
        }
      },
      "required": [
        "id",
        "event"
      ],
      "title": "AfterTrigger",
      "type": "object"
    },
    "AllOf": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "all_of",
          "title": "Kind",
          "type": "string"
        },
        "conditions": {
          "items": {
            "discriminator": {
              "mapping": {
                "all_of": "#/$defs/AllOf",
                "any_of": "#/$defs/AnyOf",
                "compare": "#/$defs/Comparison",
                "not": "#/$defs/NotCondition"
              },
              "propertyName": "kind"
            },
            "oneOf": [
              {
                "$ref": "#/$defs/Comparison"
              },
              {
                "$ref": "#/$defs/AllOf"
              },
              {
                "$ref": "#/$defs/AnyOf"
              },
              {
                "$ref": "#/$defs/NotCondition"
              }
            ]
          },
          "maxItems": 16,
          "minItems": 1,
          "title": "Conditions",
          "type": "array"
        }
      },
      "required": [
        "kind",
        "conditions"
      ],
      "title": "AllOf",
      "type": "object"
    },
    "AnyOf": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "any_of",
          "title": "Kind",
          "type": "string"
        },
        "conditions": {
          "items": {
            "discriminator": {
              "mapping": {
                "all_of": "#/$defs/AllOf",
                "any_of": "#/$defs/AnyOf",
                "compare": "#/$defs/Comparison",
                "not": "#/$defs/NotCondition"
              },
              "propertyName": "kind"
            },
            "oneOf": [
              {
                "$ref": "#/$defs/Comparison"
              },
              {
                "$ref": "#/$defs/AllOf"
              },
              {
                "$ref": "#/$defs/AnyOf"
              },
              {
                "$ref": "#/$defs/NotCondition"
              }
            ]
          },
          "maxItems": 16,
          "minItems": 1,
          "title": "Conditions",
          "type": "array"
        }
      },
      "required": [
        "kind",
        "conditions"
      ],
      "title": "AnyOf",
      "type": "object"
    },
    "ArtifactSource": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "artifact",
          "title": "Kind",
          "type": "string"
        },
        "artifact": {
          "enum": [
            "transcript",
            "analysis",
            "recording",
            "lead",
            "billing"
          ],
          "title": "Artifact",
          "type": "string"
        },
        "path": {
          "pattern": "^(|/.*)$",
          "title": "Path",
          "type": "string"
        },
        "fallback": {
          "anyOf": [
            {
              "$ref": "#/$defs/Fallback"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "kind",
        "artifact",
        "path"
      ],
      "title": "ArtifactSource",
      "type": "object"
    },
    "BeforePhase": {
      "additionalProperties": false,
      "properties": {
        "steps": {
          "items": {
            "$ref": "#/$defs/SequenceStep"
          },
          "maxItems": 256,
          "title": "Steps",
          "type": "array"
        },
        "on_failure": {
          "default": "stop_admission",
          "enum": [
            "stop_admission",
            "continue_with_available"
          ],
          "title": "On Failure",
          "type": "string"
        }
      },
      "title": "BeforePhase",
      "type": "object"
    },
    "CallSource": {
      "additionalProperties": false,
      "description": "A fact the platform recorded about the call itself, in the call package's\nown names (`/status`, `/ended_by`, `/disposition/id`, ...).\n\nRead-only and only for a follow-up's \"Only if\": a trigger filter may read\nthe call facts its event guarantees (`trigger_filter.py`), and the\npublisher refuses it anywhere else.",
      "properties": {
        "kind": {
          "const": "call",
          "title": "Kind",
          "type": "string"
        },
        "path": {
          "maxLength": 300,
          "pattern": "^/.+$",
          "title": "Path",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "path"
      ],
      "title": "CallSource",
      "type": "object"
    },
    "Comparison": {
      "additionalProperties": false,
      "description": "One declarative comparison. `value` is itself a source, so an absent\nright-hand side stays distinguishable from an explicit JSON null.",
      "properties": {
        "kind": {
          "const": "compare",
          "title": "Kind",
          "type": "string"
        },
        "source": {
          "discriminator": {
            "mapping": {
              "call": "#/$defs/CallSource",
              "literal": "#/$defs/LiteralSource",
              "request": "#/$defs/ContextSource",
              "sequence": "#/$defs/ContextSource",
              "step": "#/$defs/StepSource",
              "stored": "#/$defs/ContextSource"
            },
            "propertyName": "kind"
          },
          "oneOf": [
            {
              "$ref": "#/$defs/LiteralSource"
            },
            {
              "$ref": "#/$defs/ContextSource"
            },
            {
              "$ref": "#/$defs/StepSource"
            },
            {
              "$ref": "#/$defs/CallSource"
            }
          ],
          "title": "Source"
        },
        "op": {
          "enum": [
            "exists",
            "not_exists",
            "eq",
            "neq",
            "gt",
            "gte",
            "lt",
            "lte",
            "contains",
            "not_contains",
            "in",
            "not_in",
            "is_true",
            "is_false",
            "is_empty",
            "is_not_empty"
          ],
          "title": "Op",
          "type": "string"
        },
        "value": {
          "anyOf": [
            {
              "discriminator": {
                "mapping": {
                  "call": "#/$defs/CallSource",
                  "literal": "#/$defs/LiteralSource",
                  "request": "#/$defs/ContextSource",
                  "sequence": "#/$defs/ContextSource",
                  "step": "#/$defs/StepSource",
                  "stored": "#/$defs/ContextSource"
                },
                "propertyName": "kind"
              },
              "oneOf": [
                {
                  "$ref": "#/$defs/LiteralSource"
                },
                {
                  "$ref": "#/$defs/ContextSource"
                },
                {
                  "$ref": "#/$defs/StepSource"
                },
                {
                  "$ref": "#/$defs/CallSource"
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Value"
        }
      },
      "required": [
        "kind",
        "source",
        "op"
      ],
      "title": "Comparison",
      "type": "object"
    },
    "ContextSource": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "enum": [
            "request",
            "stored",
            "sequence"
          ],
          "title": "Kind",
          "type": "string"
        },
        "path": {
          "pattern": "^(|/.*)$",
          "title": "Path",
          "type": "string"
        },
        "fallback": {
          "anyOf": [
            {
              "$ref": "#/$defs/Fallback"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "kind",
        "path"
      ],
      "title": "ContextSource",
      "type": "object"
    },
    "ConversationEdge": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "source": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Source",
          "type": "string"
        },
        "target": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Target",
          "type": "string"
        },
        "kind": {
          "const": "conversation",
          "title": "Kind",
          "type": "string"
        },
        "condition": {
          "maxLength": 10000,
          "minLength": 1,
          "title": "Condition",
          "type": "string"
        }
      },
      "required": [
        "id",
        "source",
        "target",
        "kind",
        "condition"
      ],
      "title": "ConversationEdge",
      "type": "object"
    },
    "ConversationGraph": {
      "additionalProperties": false,
      "properties": {
        "entry_node_id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Entry Node Id",
          "type": "string"
        },
        "nodes": {
          "items": {
            "discriminator": {
              "mapping": {
                "action": "#/$defs/ActionNode",
                "conversation": "#/$defs/ConversationNode",
                "end": "#/$defs/EndNode",
                "sequence": "#/$defs/SequenceNode"
              },
              "propertyName": "type"
            },
            "oneOf": [
              {
                "$ref": "#/$defs/ConversationNode"
              },
              {
                "$ref": "#/$defs/ActionNode"
              },
              {
                "$ref": "#/$defs/SequenceNode"
              },
              {
                "$ref": "#/$defs/EndNode"
              }
            ]
          },
          "maxItems": 256,
          "minItems": 1,
          "title": "Nodes",
          "type": "array"
        },
        "edges": {
          "items": {
            "discriminator": {
              "mapping": {
                "conversation": "#/$defs/ConversationEdge",
                "result": "#/$defs/ResultEdge"
              },
              "propertyName": "kind"
            },
            "oneOf": [
              {
                "$ref": "#/$defs/ConversationEdge"
              },
              {
                "$ref": "#/$defs/ResultEdge"
              }
            ]
          },
          "maxItems": 1024,
          "title": "Edges",
          "type": "array"
        },
        "global_edges": {
          "items": {
            "$ref": "#/$defs/GlobalEdge"
          },
          "maxItems": 128,
          "title": "Global Edges",
          "type": "array"
        }
      },
      "required": [
        "entry_node_id",
        "nodes"
      ],
      "title": "ConversationGraph",
      "type": "object"
    },
    "ConversationNode": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "label": {
          "maxLength": 200,
          "minLength": 1,
          "title": "Label",
          "type": "string"
        },
        "type": {
          "const": "conversation",
          "title": "Type",
          "type": "string"
        },
        "instructions": {
          "description": "Prose may read a Before-call step's output as {{before.<step_id>.<dotted.path>}}, optionally ending with |text used when the value is missing. The publisher validates the step and the path; the value is substituted once, at session start. {{option one|option two}} - two or more plain-text options separated by |, the first not starting with before. or call. - is a random variation: one option is said, picked once per call.",
          "maxLength": 100000,
          "title": "Instructions",
          "type": "string"
        },
        "available_binding_ids": {
          "items": {
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
            "type": "string"
          },
          "maxItems": 128,
          "title": "Available Binding Ids",
          "type": "array"
        },
        "binding_overrides": {
          "anyOf": [
            {
              "additionalProperties": {
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
                "type": "string"
              },
              "propertyNames": {
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional. This step's own settings for an action the whole agent has: maps the binding id an integration (or a tool for every step) owns to a binding of this document that runs the same tool with this step's inputs.",
          "title": "Binding Overrides"
        }
      },
      "required": [
        "id",
        "label",
        "type",
        "instructions"
      ],
      "title": "ConversationNode",
      "type": "object"
    },
    "EditorMetadata": {
      "additionalProperties": false,
      "properties": {
        "positions": {
          "additionalProperties": {
            "$ref": "#/$defs/Position"
          },
          "title": "Positions",
          "type": "object"
        }
      },
      "title": "EditorMetadata",
      "type": "object"
    },
    "EndNode": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "label": {
          "maxLength": 200,
          "minLength": 1,
          "title": "Label",
          "type": "string"
        },
        "type": {
          "const": "end",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "id",
        "label",
        "type"
      ],
      "title": "EndNode",
      "type": "object"
    },
    "ExtractSource": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "extract",
          "title": "Kind",
          "type": "string"
        },
        "instruction": {
          "description": "A value the finished call is asked for by description, such as \"the time slot the caller agreed to\". Only on an After-call step. `type` is worked out from the tool input when left out. When the call does not say it: `fallback` is used, else `on_missing` decides - \"skip\" skips the step (the default for a required input), \"fail\" fails it. `fallback` and `on_missing` are not written together. Never sent as a guess.",
          "maxLength": 500,
          "minLength": 1,
          "title": "Instruction",
          "type": "string"
        },
        "type": {
          "anyOf": [
            {
              "enum": [
                "text",
                "number",
                "yes_no",
                "date",
                "datetime"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Type"
        },
        "on_missing": {
          "anyOf": [
            {
              "enum": [
                "skip",
                "fail"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "On Missing"
        },
        "fallback": {
          "anyOf": [
            {
              "$ref": "#/$defs/Fallback"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "kind",
        "instruction"
      ],
      "title": "ExtractSource",
      "type": "object"
    },
    "Fallback": {
      "additionalProperties": false,
      "properties": {
        "value": {
          "$ref": "#/$defs/JsonValue"
        }
      },
      "required": [
        "value"
      ],
      "title": "Fallback",
      "type": "object"
    },
    "GlobalEdge": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "target": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Target",
          "type": "string"
        },
        "condition": {
          "maxLength": 10000,
          "minLength": 1,
          "title": "Condition",
          "type": "string"
        }
      },
      "required": [
        "id",
        "target",
        "condition"
      ],
      "title": "GlobalEdge",
      "type": "object"
    },
    "IntegrationAction": {
      "additionalProperties": false,
      "properties": {
        "action": {
          "pattern": "^[A-Z0-9_]{1,200}$",
          "title": "Action",
          "type": "string"
        },
        "binding_id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Binding Id",
          "type": "string"
        }
      },
      "required": [
        "action",
        "binding_id"
      ],
      "title": "IntegrationAction",
      "type": "object"
    },
    "IntegrationGrant": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "connection_id": {
          "pattern": "^[a-f0-9-]{36}$",
          "title": "Connection Id",
          "type": "string"
        },
        "app": {
          "pattern": "^[a-z0-9_]{1,100}$",
          "title": "App",
          "type": "string"
        },
        "actions": {
          "items": {
            "$ref": "#/$defs/IntegrationAction"
          },
          "maxItems": 24,
          "minItems": 1,
          "title": "Actions",
          "type": "array"
        }
      },
      "required": [
        "id",
        "connection_id",
        "app",
        "actions"
      ],
      "title": "IntegrationGrant",
      "type": "object"
    },
    "JsonValue": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "boolean"
        },
        {
          "type": "number"
        },
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/JsonValue"
          }
        },
        {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/JsonValue"
          }
        }
      ]
    },
    "LiteralSource": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "literal",
          "title": "Kind",
          "type": "string"
        },
        "value": {
          "$ref": "#/$defs/JsonValue"
        }
      },
      "required": [
        "kind",
        "value"
      ],
      "title": "LiteralSource",
      "type": "object"
    },
    "ModelOption": {
      "additionalProperties": false,
      "properties": {
        "value": {
          "maxLength": 500,
          "minLength": 1,
          "title": "Value",
          "type": "string"
        },
        "label": {
          "maxLength": 120,
          "minLength": 1,
          "title": "Label",
          "type": "string"
        }
      },
      "required": [
        "value",
        "label"
      ],
      "title": "ModelOption",
      "type": "object"
    },
    "ModelSource": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "model",
          "title": "Kind",
          "type": "string"
        },
        "path": {
          "pattern": "^/[^/]+$",
          "title": "Path",
          "type": "string"
        },
        "options": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/ModelOption"
              },
              "maxItems": 20,
              "minItems": 1,
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional. The values the agent may choose from for this input, each with the label it reads. Only on a During-call binding; string values only.",
          "title": "Options"
        }
      },
      "required": [
        "kind",
        "path"
      ],
      "title": "ModelSource",
      "type": "object"
    },
    "NotCondition": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "not",
          "title": "Kind",
          "type": "string"
        },
        "condition": {
          "discriminator": {
            "mapping": {
              "all_of": "#/$defs/AllOf",
              "any_of": "#/$defs/AnyOf",
              "compare": "#/$defs/Comparison",
              "not": "#/$defs/NotCondition"
            },
            "propertyName": "kind"
          },
          "oneOf": [
            {
              "$ref": "#/$defs/Comparison"
            },
            {
              "$ref": "#/$defs/AllOf"
            },
            {
              "$ref": "#/$defs/AnyOf"
            },
            {
              "$ref": "#/$defs/NotCondition"
            }
          ],
          "title": "Condition"
        }
      },
      "required": [
        "kind",
        "condition"
      ],
      "title": "NotCondition",
      "type": "object"
    },
    "Position": {
      "additionalProperties": false,
      "properties": {
        "x": {
          "title": "X",
          "type": "number"
        },
        "y": {
          "title": "Y",
          "type": "number"
        }
      },
      "required": [
        "x",
        "y"
      ],
      "title": "Position",
      "type": "object"
    },
    "ResultEdge": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "source": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Source",
          "type": "string"
        },
        "target": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Target",
          "type": "string"
        },
        "kind": {
          "const": "result",
          "title": "Kind",
          "type": "string"
        },
        "outcome": {
          "enum": [
            "succeeded",
            "failed"
          ],
          "title": "Outcome",
          "type": "string"
        },
        "when": {
          "anyOf": [
            {
              "discriminator": {
                "mapping": {
                  "all_of": "#/$defs/AllOf",
                  "any_of": "#/$defs/AnyOf",
                  "compare": "#/$defs/Comparison",
                  "not": "#/$defs/NotCondition"
                },
                "propertyName": "kind"
              },
              "oneOf": [
                {
                  "$ref": "#/$defs/Comparison"
                },
                {
                  "$ref": "#/$defs/AllOf"
                },
                {
                  "$ref": "#/$defs/AnyOf"
                },
                {
                  "$ref": "#/$defs/NotCondition"
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional, and only on a `succeeded` route in Strict mode. The route is taken only when this condition holds for what the step's tool answered: it reads fixed values and that step's own answer ({\"kind\": \"step\", \"scope\": \"during\", \"step_id\": <this edge's source>, \"path\": \"/status\"}). A step's guarded routes are tried in the order they are written; the one `succeeded` route with no condition is taken when none of them holds, so a step that has guarded routes must have exactly one. A `failed` route never has a condition.",
          "title": "When"
        }
      },
      "required": [
        "id",
        "source",
        "target",
        "kind",
        "outcome"
      ],
      "title": "ResultEdge",
      "type": "object"
    },
    "SequenceNode": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "label": {
          "maxLength": 200,
          "minLength": 1,
          "title": "Label",
          "type": "string"
        },
        "type": {
          "const": "sequence",
          "title": "Type",
          "type": "string"
        },
        "sequence_id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Sequence Id",
          "type": "string"
        }
      },
      "required": [
        "id",
        "label",
        "type",
        "sequence_id"
      ],
      "title": "SequenceNode",
      "type": "object"
    },
    "SequenceStep": {
      "additionalProperties": false,
      "description": "A step that may carry a guard and route its outcome.\n\nSequence children use all three members. Before and After steps are the same\nshape so that a before-call step can route to `#decline`, and the publisher\nrefuses every other use of them outside a sequence with its own code — the\nmodel is wide enough to state the mistake, not wide enough to run it. The\nserializer drops the three members whenever they hold their v1 default, so a\nstep that declares no branching compiles and hashes to exactly the bytes it\ndid before they existed.",
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "label": {
          "maxLength": 200,
          "minLength": 1,
          "title": "Label",
          "type": "string"
        },
        "binding_id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Binding Id",
          "type": "string"
        },
        "depends_on": {
          "items": {
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
            "type": "string"
          },
          "maxItems": 256,
          "title": "Depends On",
          "type": "array"
        },
        "requires": {
          "items": {
            "enum": [
              "transcript",
              "analysis",
              "recording",
              "lead",
              "billing"
            ],
            "type": "string"
          },
          "title": "Requires",
          "type": "array"
        },
        "on_failure": {
          "default": "stop",
          "enum": [
            "stop",
            "continue"
          ],
          "title": "On Failure",
          "type": "string"
        },
        "when": {
          "anyOf": [
            {
              "discriminator": {
                "mapping": {
                  "all_of": "#/$defs/AllOf",
                  "any_of": "#/$defs/AnyOf",
                  "compare": "#/$defs/Comparison",
                  "not": "#/$defs/NotCondition"
                },
                "propertyName": "kind"
              },
              "oneOf": [
                {
                  "$ref": "#/$defs/Comparison"
                },
                {
                  "$ref": "#/$defs/AllOf"
                },
                {
                  "$ref": "#/$defs/AnyOf"
                },
                {
                  "$ref": "#/$defs/NotCondition"
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "When"
        },
        "on_succeeded": {
          "anyOf": [
            {
              "pattern": "^(#end|#decline|[A-Za-z0-9][A-Za-z0-9_-]{0,63})$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "On Succeeded"
        },
        "on_failed": {
          "anyOf": [
            {
              "pattern": "^(#end|#decline|[A-Za-z0-9][A-Za-z0-9_-]{0,63})$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "On Failed"
        }
      },
      "required": [
        "id",
        "label",
        "binding_id"
      ],
      "title": "SequenceStep",
      "type": "object"
    },
    "StepSource": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "step",
          "title": "Kind",
          "type": "string"
        },
        "scope": {
          "default": "local",
          "enum": [
            "local",
            "before",
            "during"
          ],
          "title": "Scope",
          "type": "string"
        },
        "step_id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Step Id",
          "type": "string"
        },
        "path": {
          "pattern": "^(|/.*)$",
          "title": "Path",
          "type": "string"
        },
        "fallback": {
          "anyOf": [
            {
              "$ref": "#/$defs/Fallback"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "kind",
        "step_id",
        "path"
      ],
      "title": "StepSource",
      "type": "object"
    },
    "ToolBinding": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "tool_revision_id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Tool Revision Id",
          "type": "string"
        },
        "tool_revision_policy": {
          "default": "follow_current",
          "enum": [
            "follow_current",
            "pinned"
          ],
          "title": "Tool Revision Policy",
          "type": "string"
        },
        "inputs": {
          "additionalProperties": {
            "discriminator": {
              "mapping": {
                "artifact": "#/$defs/ArtifactSource",
                "extract": "#/$defs/ExtractSource",
                "literal": "#/$defs/LiteralSource",
                "model": "#/$defs/ModelSource",
                "request": "#/$defs/ContextSource",
                "sequence": "#/$defs/ContextSource",
                "step": "#/$defs/StepSource",
                "stored": "#/$defs/ContextSource"
              },
              "propertyName": "kind"
            },
            "oneOf": [
              {
                "$ref": "#/$defs/LiteralSource"
              },
              {
                "$ref": "#/$defs/ModelSource"
              },
              {
                "$ref": "#/$defs/ContextSource"
              },
              {
                "$ref": "#/$defs/StepSource"
              },
              {
                "$ref": "#/$defs/ArtifactSource"
              },
              {
                "$ref": "#/$defs/ExtractSource"
              }
            ]
          },
          "title": "Inputs",
          "type": "object"
        }
      },
      "required": [
        "id",
        "tool_revision_id"
      ],
      "title": "ToolBinding",
      "type": "object"
    },
    "ToolGrant": {
      "additionalProperties": false,
      "description": "A saved webhook or call transfer the agent may use on every conversation step.\n\nLives in the same `integrations` list as the app grants (the two shapes\nshare no member, so the list stays unambiguous). `binding_id` names one\nbinding in `bindings` that runs `tool_id`; the save path offers it on every\nconversation step, as it does an app grant's actions.",
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "tool_id": {
          "pattern": "^[a-f0-9-]{36}$",
          "title": "Tool Id",
          "type": "string"
        },
        "binding_id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Binding Id",
          "type": "string"
        }
      },
      "required": [
        "id",
        "tool_id",
        "binding_id"
      ],
      "title": "ToolGrant",
      "type": "object"
    },
    "ToolSequence": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
          "title": "Id",
          "type": "string"
        },
        "name": {
          "maxLength": 200,
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "description": {
          "default": "",
          "maxLength": 10000,
          "title": "Description",
          "type": "string"
        },
        "input_schema": {
          "additionalProperties": {
            "$ref": "#/$defs/JsonValue"
          },
          "title": "Input Schema",
          "type": "object"
        },
        "output_schema": {
          "additionalProperties": {
            "$ref": "#/$defs/JsonValue"
          },
          "title": "Output Schema",
          "type": "object"
        },
        "output_mapping": {
          "additionalProperties": {
            "$ref": "#/$defs/StepSource"
          },
          "title": "Output Mapping",
          "type": "object"
        },
        "steps": {
          "items": {
            "$ref": "#/$defs/SequenceStep"
          },
          "maxItems": 128,
          "minItems": 1,
          "title": "Steps",
          "type": "array"
        }
      },
      "required": [
        "id",
        "name",
        "steps"
      ],
      "title": "ToolSequence",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": "1",
      "default": "1",
      "title": "Schema Version",
      "type": "string"
    },
    "id": {
      "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
      "title": "Id",
      "type": "string"
    },
    "name": {
      "maxLength": 200,
      "minLength": 1,
      "title": "Name",
      "type": "string"
    },
    "strict_mode": {
      "default": false,
      "title": "Strict Mode",
      "type": "boolean"
    },
    "global_instructions": {
      "default": "",
      "description": "Prose may read a Before-call step's output as {{before.<step_id>.<dotted.path>}}, optionally ending with |text used when the value is missing. The publisher validates the step and the path; the value is substituted once, at session start. {{option one|option two}} - two or more plain-text options separated by |, the first not starting with before. or call. - is a random variation: one option is said, picked once per call.",
      "maxLength": 100000,
      "title": "Global Instructions",
      "type": "string"
    },
    "channels": {
      "items": {
        "enum": [
          "phone",
          "web"
        ],
        "type": "string"
      },
      "minItems": 1,
      "title": "Channels",
      "type": "array"
    },
    "request_schema": {
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      },
      "title": "Request Schema",
      "type": "object"
    },
    "stored_schema": {
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      },
      "title": "Stored Schema",
      "type": "object"
    },
    "bindings": {
      "items": {
        "$ref": "#/$defs/ToolBinding"
      },
      "maxItems": 512,
      "title": "Bindings",
      "type": "array"
    },
    "before": {
      "$ref": "#/$defs/BeforePhase"
    },
    "conversation": {
      "$ref": "#/$defs/ConversationGraph"
    },
    "after": {
      "items": {
        "$ref": "#/$defs/AfterTrigger"
      },
      "maxItems": 64,
      "title": "After",
      "type": "array"
    },
    "sequences": {
      "items": {
        "$ref": "#/$defs/ToolSequence"
      },
      "maxItems": 64,
      "title": "Sequences",
      "type": "array"
    },
    "editor": {
      "$ref": "#/$defs/EditorMetadata"
    },
    "integrations": {
      "description": "Tools & integrations this agent may use on every step: connected apps (one entry per connected account, at most 8) and saved webhooks or call transfers (one entry per tool, at most 8). Each action names a binding in bindings; the save path offers every one of them on every conversation step. Manage them with /agents/{id}/integrations rather than by hand.",
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/IntegrationGrant"
          },
          {
            "$ref": "#/$defs/ToolGrant"
          }
        ]
      },
      "maxItems": 16,
      "title": "Integrations",
      "type": "array"
    }
  },
  "required": [
    "id",
    "name",
    "conversation"
  ],
  "title": "WorkflowDefinition",
  "type": "object",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://yappr.ai/schemas/workflow-v1.json"
}
