{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://clawdbot.dev/protocol.schema.json",
  "title": "Clawdbot Gateway Protocol",
  "description": "Handshake, request/response, and event frames for the Gateway WebSocket.",
  "oneOf": [
    {
      "$ref": "#/definitions/RequestFrame"
    },
    {
      "$ref": "#/definitions/ResponseFrame"
    },
    {
      "$ref": "#/definitions/EventFrame"
    }
  ],
  "discriminator": {
    "propertyName": "type",
    "mapping": {
      "req": "#/definitions/RequestFrame",
      "res": "#/definitions/ResponseFrame",
      "event": "#/definitions/EventFrame"
    }
  },
  "definitions": {
    "ConnectParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "minProtocol",
        "maxProtocol",
        "client"
      ],
      "properties": {
        "minProtocol": {
          "minimum": 1,
          "type": "integer"
        },
        "maxProtocol": {
          "minimum": 1,
          "type": "integer"
        },
        "client": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "id",
            "version",
            "platform",
            "mode"
          ],
          "properties": {
            "id": {
              "anyOf": [
                {
                  "const": "webchat-ui",
                  "type": "string"
                },
                {
                  "const": "clawdbot-control-ui",
                  "type": "string"
                },
                {
                  "const": "webchat",
                  "type": "string"
                },
                {
                  "const": "cli",
                  "type": "string"
                },
                {
                  "const": "gateway-client",
                  "type": "string"
                },
                {
                  "const": "clawdbot-macos",
                  "type": "string"
                },
                {
                  "const": "test",
                  "type": "string"
                },
                {
                  "const": "fingerprint",
                  "type": "string"
                },
                {
                  "const": "clawdbot-probe",
                  "type": "string"
                }
              ]
            },
            "displayName": {
              "minLength": 1,
              "type": "string"
            },
            "version": {
              "minLength": 1,
              "type": "string"
            },
            "platform": {
              "minLength": 1,
              "type": "string"
            },
            "deviceFamily": {
              "minLength": 1,
              "type": "string"
            },
            "modelIdentifier": {
              "minLength": 1,
              "type": "string"
            },
            "mode": {
              "anyOf": [
                {
                  "const": "webchat",
                  "type": "string"
                },
                {
                  "const": "cli",
                  "type": "string"
                },
                {
                  "const": "ui",
                  "type": "string"
                },
                {
                  "const": "backend",
                  "type": "string"
                },
                {
                  "const": "probe",
                  "type": "string"
                },
                {
                  "const": "test",
                  "type": "string"
                }
              ]
            },
            "instanceId": {
              "minLength": 1,
              "type": "string"
            }
          }
        },
        "caps": {
          "default": [],
          "type": "array",
          "items": {
            "minLength": 1,
            "type": "string"
          }
        },
        "auth": {
          "additionalProperties": false,
          "type": "object",
          "properties": {
            "token": {
              "type": "string"
            },
            "password": {
              "type": "string"
            }
          }
        },
        "locale": {
          "type": "string"
        },
        "userAgent": {
          "type": "string"
        }
      }
    },
    "HelloOk": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type",
        "protocol",
        "server",
        "features",
        "snapshot",
        "policy"
      ],
      "properties": {
        "type": {
          "const": "hello-ok",
          "type": "string"
        },
        "protocol": {
          "minimum": 1,
          "type": "integer"
        },
        "server": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "version",
            "connId"
          ],
          "properties": {
            "version": {
              "minLength": 1,
              "type": "string"
            },
            "commit": {
              "minLength": 1,
              "type": "string"
            },
            "host": {
              "minLength": 1,
              "type": "string"
            },
            "connId": {
              "minLength": 1,
              "type": "string"
            }
          }
        },
        "features": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "methods",
            "events"
          ],
          "properties": {
            "methods": {
              "type": "array",
              "items": {
                "minLength": 1,
                "type": "string"
              }
            },
            "events": {
              "type": "array",
              "items": {
                "minLength": 1,
                "type": "string"
              }
            }
          }
        },
        "snapshot": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "presence",
            "health",
            "stateVersion",
            "uptimeMs"
          ],
          "properties": {
            "presence": {
              "type": "array",
              "items": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ts"
                ],
                "properties": {
                  "host": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "ip": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "version": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "platform": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "deviceFamily": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "modelIdentifier": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "mode": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "lastInputSeconds": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "reason": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "text": {
                    "type": "string"
                  },
                  "ts": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "instanceId": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            },
            "health": {},
            "stateVersion": {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "presence",
                "health"
              ],
              "properties": {
                "presence": {
                  "minimum": 0,
                  "type": "integer"
                },
                "health": {
                  "minimum": 0,
                  "type": "integer"
                }
              }
            },
            "uptimeMs": {
              "minimum": 0,
              "type": "integer"
            },
            "configPath": {
              "minLength": 1,
              "type": "string"
            },
            "stateDir": {
              "minLength": 1,
              "type": "string"
            }
          }
        },
        "canvasHostUrl": {
          "minLength": 1,
          "type": "string"
        },
        "policy": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "maxPayload",
            "maxBufferedBytes",
            "tickIntervalMs"
          ],
          "properties": {
            "maxPayload": {
              "minimum": 1,
              "type": "integer"
            },
            "maxBufferedBytes": {
              "minimum": 1,
              "type": "integer"
            },
            "tickIntervalMs": {
              "minimum": 1,
              "type": "integer"
            }
          }
        }
      }
    },
    "RequestFrame": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type",
        "id",
        "method"
      ],
      "properties": {
        "type": {
          "const": "req",
          "type": "string"
        },
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "method": {
          "minLength": 1,
          "type": "string"
        },
        "params": {}
      }
    },
    "ResponseFrame": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type",
        "id",
        "ok"
      ],
      "properties": {
        "type": {
          "const": "res",
          "type": "string"
        },
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "ok": {
          "type": "boolean"
        },
        "payload": {},
        "error": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "code",
            "message"
          ],
          "properties": {
            "code": {
              "minLength": 1,
              "type": "string"
            },
            "message": {
              "minLength": 1,
              "type": "string"
            },
            "details": {},
            "retryable": {
              "type": "boolean"
            },
            "retryAfterMs": {
              "minimum": 0,
              "type": "integer"
            }
          }
        }
      }
    },
    "EventFrame": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type",
        "event"
      ],
      "properties": {
        "type": {
          "const": "event",
          "type": "string"
        },
        "event": {
          "minLength": 1,
          "type": "string"
        },
        "payload": {},
        "seq": {
          "minimum": 0,
          "type": "integer"
        },
        "stateVersion": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "presence",
            "health"
          ],
          "properties": {
            "presence": {
              "minimum": 0,
              "type": "integer"
            },
            "health": {
              "minimum": 0,
              "type": "integer"
            }
          }
        }
      }
    },
    "GatewayFrame": {
      "discriminator": "type",
      "anyOf": [
        {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "type",
            "id",
            "method"
          ],
          "properties": {
            "type": {
              "const": "req",
              "type": "string"
            },
            "id": {
              "minLength": 1,
              "type": "string"
            },
            "method": {
              "minLength": 1,
              "type": "string"
            },
            "params": {}
          }
        },
        {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "type",
            "id",
            "ok"
          ],
          "properties": {
            "type": {
              "const": "res",
              "type": "string"
            },
            "id": {
              "minLength": 1,
              "type": "string"
            },
            "ok": {
              "type": "boolean"
            },
            "payload": {},
            "error": {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "code",
                "message"
              ],
              "properties": {
                "code": {
                  "minLength": 1,
                  "type": "string"
                },
                "message": {
                  "minLength": 1,
                  "type": "string"
                },
                "details": {},
                "retryable": {
                  "type": "boolean"
                },
                "retryAfterMs": {
                  "minimum": 0,
                  "type": "integer"
                }
              }
            }
          }
        },
        {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "type",
            "event"
          ],
          "properties": {
            "type": {
              "const": "event",
              "type": "string"
            },
            "event": {
              "minLength": 1,
              "type": "string"
            },
            "payload": {},
            "seq": {
              "minimum": 0,
              "type": "integer"
            },
            "stateVersion": {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "presence",
                "health"
              ],
              "properties": {
                "presence": {
                  "minimum": 0,
                  "type": "integer"
                },
                "health": {
                  "minimum": 0,
                  "type": "integer"
                }
              }
            }
          }
        }
      ]
    },
    "PresenceEntry": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "ts"
      ],
      "properties": {
        "host": {
          "minLength": 1,
          "type": "string"
        },
        "ip": {
          "minLength": 1,
          "type": "string"
        },
        "version": {
          "minLength": 1,
          "type": "string"
        },
        "platform": {
          "minLength": 1,
          "type": "string"
        },
        "deviceFamily": {
          "minLength": 1,
          "type": "string"
        },
        "modelIdentifier": {
          "minLength": 1,
          "type": "string"
        },
        "mode": {
          "minLength": 1,
          "type": "string"
        },
        "lastInputSeconds": {
          "minimum": 0,
          "type": "integer"
        },
        "reason": {
          "minLength": 1,
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "minLength": 1,
            "type": "string"
          }
        },
        "text": {
          "type": "string"
        },
        "ts": {
          "minimum": 0,
          "type": "integer"
        },
        "instanceId": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "StateVersion": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "presence",
        "health"
      ],
      "properties": {
        "presence": {
          "minimum": 0,
          "type": "integer"
        },
        "health": {
          "minimum": 0,
          "type": "integer"
        }
      }
    },
    "Snapshot": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "presence",
        "health",
        "stateVersion",
        "uptimeMs"
      ],
      "properties": {
        "presence": {
          "type": "array",
          "items": {
            "additionalProperties": false,
            "type": "object",
            "required": [
              "ts"
            ],
            "properties": {
              "host": {
                "minLength": 1,
                "type": "string"
              },
              "ip": {
                "minLength": 1,
                "type": "string"
              },
              "version": {
                "minLength": 1,
                "type": "string"
              },
              "platform": {
                "minLength": 1,
                "type": "string"
              },
              "deviceFamily": {
                "minLength": 1,
                "type": "string"
              },
              "modelIdentifier": {
                "minLength": 1,
                "type": "string"
              },
              "mode": {
                "minLength": 1,
                "type": "string"
              },
              "lastInputSeconds": {
                "minimum": 0,
                "type": "integer"
              },
              "reason": {
                "minLength": 1,
                "type": "string"
              },
              "tags": {
                "type": "array",
                "items": {
                  "minLength": 1,
                  "type": "string"
                }
              },
              "text": {
                "type": "string"
              },
              "ts": {
                "minimum": 0,
                "type": "integer"
              },
              "instanceId": {
                "minLength": 1,
                "type": "string"
              }
            }
          }
        },
        "health": {},
        "stateVersion": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "presence",
            "health"
          ],
          "properties": {
            "presence": {
              "minimum": 0,
              "type": "integer"
            },
            "health": {
              "minimum": 0,
              "type": "integer"
            }
          }
        },
        "uptimeMs": {
          "minimum": 0,
          "type": "integer"
        },
        "configPath": {
          "minLength": 1,
          "type": "string"
        },
        "stateDir": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "ErrorShape": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "minLength": 1,
          "type": "string"
        },
        "message": {
          "minLength": 1,
          "type": "string"
        },
        "details": {},
        "retryable": {
          "type": "boolean"
        },
        "retryAfterMs": {
          "minimum": 0,
          "type": "integer"
        }
      }
    },
    "AgentEvent": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "runId",
        "seq",
        "stream",
        "ts",
        "data"
      ],
      "properties": {
        "runId": {
          "minLength": 1,
          "type": "string"
        },
        "seq": {
          "minimum": 0,
          "type": "integer"
        },
        "stream": {
          "minLength": 1,
          "type": "string"
        },
        "ts": {
          "minimum": 0,
          "type": "integer"
        },
        "data": {
          "type": "object",
          "patternProperties": {
            "^(.*)$": {}
          }
        }
      }
    },
    "SendParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "to",
        "message",
        "idempotencyKey"
      ],
      "properties": {
        "to": {
          "minLength": 1,
          "type": "string"
        },
        "message": {
          "minLength": 1,
          "type": "string"
        },
        "mediaUrl": {
          "type": "string"
        },
        "gifPlayback": {
          "type": "boolean"
        },
        "provider": {
          "type": "string"
        },
        "accountId": {
          "type": "string"
        },
        "idempotencyKey": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "PollParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "to",
        "question",
        "options",
        "idempotencyKey"
      ],
      "properties": {
        "to": {
          "minLength": 1,
          "type": "string"
        },
        "question": {
          "minLength": 1,
          "type": "string"
        },
        "options": {
          "minItems": 2,
          "maxItems": 12,
          "type": "array",
          "items": {
            "minLength": 1,
            "type": "string"
          }
        },
        "maxSelections": {
          "minimum": 1,
          "maximum": 12,
          "type": "integer"
        },
        "durationHours": {
          "minimum": 1,
          "type": "integer"
        },
        "provider": {
          "type": "string"
        },
        "accountId": {
          "type": "string"
        },
        "idempotencyKey": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "AgentParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "message",
        "idempotencyKey"
      ],
      "properties": {
        "message": {
          "minLength": 1,
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "sessionId": {
          "type": "string"
        },
        "sessionKey": {
          "type": "string"
        },
        "thinking": {
          "type": "string"
        },
        "deliver": {
          "type": "boolean"
        },
        "attachments": {
          "type": "array",
          "items": {}
        },
        "provider": {
          "type": "string"
        },
        "timeout": {
          "minimum": 0,
          "type": "integer"
        },
        "lane": {
          "type": "string"
        },
        "extraSystemPrompt": {
          "type": "string"
        },
        "idempotencyKey": {
          "minLength": 1,
          "type": "string"
        },
        "label": {
          "minLength": 1,
          "maxLength": 64,
          "type": "string"
        },
        "spawnedBy": {
          "type": "string"
        }
      }
    },
    "AgentWaitParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "runId"
      ],
      "properties": {
        "runId": {
          "minLength": 1,
          "type": "string"
        },
        "timeoutMs": {
          "minimum": 0,
          "type": "integer"
        }
      }
    },
    "WakeParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "mode",
        "text"
      ],
      "properties": {
        "mode": {
          "anyOf": [
            {
              "const": "now",
              "type": "string"
            },
            {
              "const": "next-heartbeat",
              "type": "string"
            }
          ]
        },
        "text": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "NodePairRequestParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "nodeId"
      ],
      "properties": {
        "nodeId": {
          "minLength": 1,
          "type": "string"
        },
        "displayName": {
          "minLength": 1,
          "type": "string"
        },
        "platform": {
          "minLength": 1,
          "type": "string"
        },
        "version": {
          "minLength": 1,
          "type": "string"
        },
        "deviceFamily": {
          "minLength": 1,
          "type": "string"
        },
        "modelIdentifier": {
          "minLength": 1,
          "type": "string"
        },
        "caps": {
          "type": "array",
          "items": {
            "minLength": 1,
            "type": "string"
          }
        },
        "commands": {
          "type": "array",
          "items": {
            "minLength": 1,
            "type": "string"
          }
        },
        "remoteIp": {
          "minLength": 1,
          "type": "string"
        },
        "silent": {
          "type": "boolean"
        }
      }
    },
    "NodePairListParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {}
    },
    "NodePairApproveParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "requestId"
      ],
      "properties": {
        "requestId": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "NodePairRejectParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "requestId"
      ],
      "properties": {
        "requestId": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "NodePairVerifyParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "nodeId",
        "token"
      ],
      "properties": {
        "nodeId": {
          "minLength": 1,
          "type": "string"
        },
        "token": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "NodeRenameParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "nodeId",
        "displayName"
      ],
      "properties": {
        "nodeId": {
          "minLength": 1,
          "type": "string"
        },
        "displayName": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "NodeListParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {}
    },
    "NodeDescribeParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "nodeId"
      ],
      "properties": {
        "nodeId": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "NodeInvokeParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "nodeId",
        "command",
        "idempotencyKey"
      ],
      "properties": {
        "nodeId": {
          "minLength": 1,
          "type": "string"
        },
        "command": {
          "minLength": 1,
          "type": "string"
        },
        "params": {},
        "timeoutMs": {
          "minimum": 0,
          "type": "integer"
        },
        "idempotencyKey": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "SessionsListParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "limit": {
          "minimum": 1,
          "type": "integer"
        },
        "activeMinutes": {
          "minimum": 1,
          "type": "integer"
        },
        "includeGlobal": {
          "type": "boolean"
        },
        "includeUnknown": {
          "type": "boolean"
        },
        "label": {
          "minLength": 1,
          "maxLength": 64,
          "type": "string"
        },
        "spawnedBy": {
          "minLength": 1,
          "type": "string"
        },
        "agentId": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "SessionsResolveParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "key": {
          "minLength": 1,
          "type": "string"
        },
        "label": {
          "minLength": 1,
          "maxLength": 64,
          "type": "string"
        },
        "agentId": {
          "minLength": 1,
          "type": "string"
        },
        "spawnedBy": {
          "minLength": 1,
          "type": "string"
        },
        "includeGlobal": {
          "type": "boolean"
        },
        "includeUnknown": {
          "type": "boolean"
        }
      }
    },
    "SessionsPatchParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "key"
      ],
      "properties": {
        "key": {
          "minLength": 1,
          "type": "string"
        },
        "label": {
          "anyOf": [
            {
              "minLength": 1,
              "maxLength": 64,
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "thinkingLevel": {
          "anyOf": [
            {
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "verboseLevel": {
          "anyOf": [
            {
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "reasoningLevel": {
          "anyOf": [
            {
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "responseUsage": {
          "anyOf": [
            {
              "const": "on",
              "type": "string"
            },
            {
              "const": "off",
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "elevatedLevel": {
          "anyOf": [
            {
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "model": {
          "anyOf": [
            {
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "spawnedBy": {
          "anyOf": [
            {
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "sendPolicy": {
          "anyOf": [
            {
              "const": "allow",
              "type": "string"
            },
            {
              "const": "deny",
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "groupActivation": {
          "anyOf": [
            {
              "const": "mention",
              "type": "string"
            },
            {
              "const": "always",
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "SessionsResetParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "key"
      ],
      "properties": {
        "key": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "SessionsDeleteParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "key"
      ],
      "properties": {
        "key": {
          "minLength": 1,
          "type": "string"
        },
        "deleteTranscript": {
          "type": "boolean"
        }
      }
    },
    "SessionsCompactParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "key"
      ],
      "properties": {
        "key": {
          "minLength": 1,
          "type": "string"
        },
        "maxLines": {
          "minimum": 1,
          "type": "integer"
        }
      }
    },
    "ConfigGetParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {}
    },
    "ConfigSetParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "raw"
      ],
      "properties": {
        "raw": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "ConfigApplyParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "raw"
      ],
      "properties": {
        "raw": {
          "minLength": 1,
          "type": "string"
        },
        "sessionKey": {
          "type": "string"
        },
        "note": {
          "type": "string"
        },
        "restartDelayMs": {
          "minimum": 0,
          "type": "integer"
        }
      }
    },
    "ConfigSchemaParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {}
    },
    "ConfigSchemaResponse": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "schema",
        "uiHints",
        "version",
        "generatedAt"
      ],
      "properties": {
        "schema": {},
        "uiHints": {
          "type": "object",
          "patternProperties": {
            "^(.*)$": {
              "additionalProperties": false,
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "help": {
                  "type": "string"
                },
                "group": {
                  "type": "string"
                },
                "order": {
                  "type": "integer"
                },
                "advanced": {
                  "type": "boolean"
                },
                "sensitive": {
                  "type": "boolean"
                },
                "placeholder": {
                  "type": "string"
                },
                "itemTemplate": {}
              }
            }
          }
        },
        "version": {
          "minLength": 1,
          "type": "string"
        },
        "generatedAt": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "WizardStartParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "mode": {
          "anyOf": [
            {
              "const": "local",
              "type": "string"
            },
            {
              "const": "remote",
              "type": "string"
            }
          ]
        },
        "workspace": {
          "type": "string"
        }
      }
    },
    "WizardNextParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "sessionId"
      ],
      "properties": {
        "sessionId": {
          "minLength": 1,
          "type": "string"
        },
        "answer": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "stepId"
          ],
          "properties": {
            "stepId": {
              "minLength": 1,
              "type": "string"
            },
            "value": {}
          }
        }
      }
    },
    "WizardCancelParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "sessionId"
      ],
      "properties": {
        "sessionId": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "WizardStatusParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "sessionId"
      ],
      "properties": {
        "sessionId": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "WizardStep": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "type"
      ],
      "properties": {
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "type": {
          "anyOf": [
            {
              "const": "note",
              "type": "string"
            },
            {
              "const": "select",
              "type": "string"
            },
            {
              "const": "text",
              "type": "string"
            },
            {
              "const": "confirm",
              "type": "string"
            },
            {
              "const": "multiselect",
              "type": "string"
            },
            {
              "const": "progress",
              "type": "string"
            },
            {
              "const": "action",
              "type": "string"
            }
          ]
        },
        "title": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "options": {
          "type": "array",
          "items": {
            "additionalProperties": false,
            "type": "object",
            "required": [
              "value",
              "label"
            ],
            "properties": {
              "value": {},
              "label": {
                "minLength": 1,
                "type": "string"
              },
              "hint": {
                "type": "string"
              }
            }
          }
        },
        "initialValue": {},
        "placeholder": {
          "type": "string"
        },
        "sensitive": {
          "type": "boolean"
        },
        "executor": {
          "anyOf": [
            {
              "const": "gateway",
              "type": "string"
            },
            {
              "const": "client",
              "type": "string"
            }
          ]
        }
      }
    },
    "WizardNextResult": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "done"
      ],
      "properties": {
        "done": {
          "type": "boolean"
        },
        "step": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "id",
            "type"
          ],
          "properties": {
            "id": {
              "minLength": 1,
              "type": "string"
            },
            "type": {
              "anyOf": [
                {
                  "const": "note",
                  "type": "string"
                },
                {
                  "const": "select",
                  "type": "string"
                },
                {
                  "const": "text",
                  "type": "string"
                },
                {
                  "const": "confirm",
                  "type": "string"
                },
                {
                  "const": "multiselect",
                  "type": "string"
                },
                {
                  "const": "progress",
                  "type": "string"
                },
                {
                  "const": "action",
                  "type": "string"
                }
              ]
            },
            "title": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "options": {
              "type": "array",
              "items": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "value",
                  "label"
                ],
                "properties": {
                  "value": {},
                  "label": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "hint": {
                    "type": "string"
                  }
                }
              }
            },
            "initialValue": {},
            "placeholder": {
              "type": "string"
            },
            "sensitive": {
              "type": "boolean"
            },
            "executor": {
              "anyOf": [
                {
                  "const": "gateway",
                  "type": "string"
                },
                {
                  "const": "client",
                  "type": "string"
                }
              ]
            }
          }
        },
        "status": {
          "anyOf": [
            {
              "const": "running",
              "type": "string"
            },
            {
              "const": "done",
              "type": "string"
            },
            {
              "const": "cancelled",
              "type": "string"
            },
            {
              "const": "error",
              "type": "string"
            }
          ]
        },
        "error": {
          "type": "string"
        }
      }
    },
    "WizardStartResult": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "sessionId",
        "done"
      ],
      "properties": {
        "sessionId": {
          "minLength": 1,
          "type": "string"
        },
        "done": {
          "type": "boolean"
        },
        "step": {
          "additionalProperties": false,
          "type": "object",
          "required": [
            "id",
            "type"
          ],
          "properties": {
            "id": {
              "minLength": 1,
              "type": "string"
            },
            "type": {
              "anyOf": [
                {
                  "const": "note",
                  "type": "string"
                },
                {
                  "const": "select",
                  "type": "string"
                },
                {
                  "const": "text",
                  "type": "string"
                },
                {
                  "const": "confirm",
                  "type": "string"
                },
                {
                  "const": "multiselect",
                  "type": "string"
                },
                {
                  "const": "progress",
                  "type": "string"
                },
                {
                  "const": "action",
                  "type": "string"
                }
              ]
            },
            "title": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "options": {
              "type": "array",
              "items": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "value",
                  "label"
                ],
                "properties": {
                  "value": {},
                  "label": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "hint": {
                    "type": "string"
                  }
                }
              }
            },
            "initialValue": {},
            "placeholder": {
              "type": "string"
            },
            "sensitive": {
              "type": "boolean"
            },
            "executor": {
              "anyOf": [
                {
                  "const": "gateway",
                  "type": "string"
                },
                {
                  "const": "client",
                  "type": "string"
                }
              ]
            }
          }
        },
        "status": {
          "anyOf": [
            {
              "const": "running",
              "type": "string"
            },
            {
              "const": "done",
              "type": "string"
            },
            {
              "const": "cancelled",
              "type": "string"
            },
            {
              "const": "error",
              "type": "string"
            }
          ]
        },
        "error": {
          "type": "string"
        }
      }
    },
    "WizardStatusResult": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "anyOf": [
            {
              "const": "running",
              "type": "string"
            },
            {
              "const": "done",
              "type": "string"
            },
            {
              "const": "cancelled",
              "type": "string"
            },
            {
              "const": "error",
              "type": "string"
            }
          ]
        },
        "error": {
          "type": "string"
        }
      }
    },
    "TalkModeParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "enabled"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "phase": {
          "type": "string"
        }
      }
    },
    "ProvidersStatusParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "probe": {
          "type": "boolean"
        },
        "timeoutMs": {
          "minimum": 0,
          "type": "integer"
        }
      }
    },
    "ProvidersStatusResult": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "ts",
        "providerOrder",
        "providerLabels",
        "providers",
        "providerAccounts",
        "providerDefaultAccountId"
      ],
      "properties": {
        "ts": {
          "minimum": 0,
          "type": "integer"
        },
        "providerOrder": {
          "type": "array",
          "items": {
            "minLength": 1,
            "type": "string"
          }
        },
        "providerLabels": {
          "type": "object",
          "patternProperties": {
            "^(.*)$": {
              "minLength": 1,
              "type": "string"
            }
          }
        },
        "providers": {
          "type": "object",
          "patternProperties": {
            "^(.*)$": {}
          }
        },
        "providerAccounts": {
          "type": "object",
          "patternProperties": {
            "^(.*)$": {
              "type": "array",
              "items": {
                "additionalProperties": true,
                "type": "object",
                "required": [
                  "accountId"
                ],
                "properties": {
                  "accountId": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "configured": {
                    "type": "boolean"
                  },
                  "linked": {
                    "type": "boolean"
                  },
                  "running": {
                    "type": "boolean"
                  },
                  "connected": {
                    "type": "boolean"
                  },
                  "reconnectAttempts": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "lastConnectedAt": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "lastError": {
                    "type": "string"
                  },
                  "lastStartAt": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "lastStopAt": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "lastInboundAt": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "lastOutboundAt": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "lastProbeAt": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "mode": {
                    "type": "string"
                  },
                  "dmPolicy": {
                    "type": "string"
                  },
                  "allowFrom": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "tokenSource": {
                    "type": "string"
                  },
                  "botTokenSource": {
                    "type": "string"
                  },
                  "appTokenSource": {
                    "type": "string"
                  },
                  "baseUrl": {
                    "type": "string"
                  },
                  "allowUnmentionedGroups": {
                    "type": "boolean"
                  },
                  "cliPath": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dbPath": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "port": {
                    "anyOf": [
                      {
                        "minimum": 0,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "probe": {},
                  "audit": {},
                  "application": {}
                }
              }
            }
          }
        },
        "providerDefaultAccountId": {
          "type": "object",
          "patternProperties": {
            "^(.*)$": {
              "minLength": 1,
              "type": "string"
            }
          }
        }
      }
    },
    "ProvidersLogoutParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "provider"
      ],
      "properties": {
        "provider": {
          "minLength": 1,
          "type": "string"
        },
        "accountId": {
          "type": "string"
        }
      }
    },
    "WebLoginStartParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "force": {
          "type": "boolean"
        },
        "timeoutMs": {
          "minimum": 0,
          "type": "integer"
        },
        "verbose": {
          "type": "boolean"
        },
        "accountId": {
          "type": "string"
        }
      }
    },
    "WebLoginWaitParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "timeoutMs": {
          "minimum": 0,
          "type": "integer"
        },
        "accountId": {
          "type": "string"
        }
      }
    },
    "AgentSummary": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "name": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "AgentsListParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {}
    },
    "AgentsListResult": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "defaultId",
        "mainKey",
        "scope",
        "agents"
      ],
      "properties": {
        "defaultId": {
          "minLength": 1,
          "type": "string"
        },
        "mainKey": {
          "minLength": 1,
          "type": "string"
        },
        "scope": {
          "anyOf": [
            {
              "const": "per-sender",
              "type": "string"
            },
            {
              "const": "global",
              "type": "string"
            }
          ]
        },
        "agents": {
          "type": "array",
          "items": {
            "additionalProperties": false,
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "minLength": 1,
                "type": "string"
              },
              "name": {
                "minLength": 1,
                "type": "string"
              }
            }
          }
        }
      }
    },
    "ModelChoice": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "name",
        "provider"
      ],
      "properties": {
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "name": {
          "minLength": 1,
          "type": "string"
        },
        "provider": {
          "minLength": 1,
          "type": "string"
        },
        "contextWindow": {
          "minimum": 1,
          "type": "integer"
        },
        "reasoning": {
          "type": "boolean"
        }
      }
    },
    "ModelsListParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {}
    },
    "ModelsListResult": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "models"
      ],
      "properties": {
        "models": {
          "type": "array",
          "items": {
            "additionalProperties": false,
            "type": "object",
            "required": [
              "id",
              "name",
              "provider"
            ],
            "properties": {
              "id": {
                "minLength": 1,
                "type": "string"
              },
              "name": {
                "minLength": 1,
                "type": "string"
              },
              "provider": {
                "minLength": 1,
                "type": "string"
              },
              "contextWindow": {
                "minimum": 1,
                "type": "integer"
              },
              "reasoning": {
                "type": "boolean"
              }
            }
          }
        }
      }
    },
    "SkillsStatusParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {}
    },
    "SkillsInstallParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "installId"
      ],
      "properties": {
        "name": {
          "minLength": 1,
          "type": "string"
        },
        "installId": {
          "minLength": 1,
          "type": "string"
        },
        "timeoutMs": {
          "minimum": 1000,
          "type": "integer"
        }
      }
    },
    "SkillsUpdateParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "skillKey"
      ],
      "properties": {
        "skillKey": {
          "minLength": 1,
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "apiKey": {
          "type": "string"
        },
        "env": {
          "type": "object",
          "patternProperties": {
            "^(.*)$": {
              "type": "string"
            }
          }
        }
      }
    },
    "CronJob": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "name",
        "enabled",
        "createdAtMs",
        "updatedAtMs",
        "schedule",
        "sessionTarget",
        "wakeMode",
        "payload",
        "state"
      ],
      "properties": {
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "name": {
          "minLength": 1,
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "createdAtMs": {
          "minimum": 0,
          "type": "integer"
        },
        "updatedAtMs": {
          "minimum": 0,
          "type": "integer"
        },
        "schedule": {
          "anyOf": [
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "atMs"
              ],
              "properties": {
                "kind": {
                  "const": "at",
                  "type": "string"
                },
                "atMs": {
                  "minimum": 0,
                  "type": "integer"
                }
              }
            },
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "everyMs"
              ],
              "properties": {
                "kind": {
                  "const": "every",
                  "type": "string"
                },
                "everyMs": {
                  "minimum": 1,
                  "type": "integer"
                },
                "anchorMs": {
                  "minimum": 0,
                  "type": "integer"
                }
              }
            },
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "expr"
              ],
              "properties": {
                "kind": {
                  "const": "cron",
                  "type": "string"
                },
                "expr": {
                  "minLength": 1,
                  "type": "string"
                },
                "tz": {
                  "type": "string"
                }
              }
            }
          ]
        },
        "sessionTarget": {
          "anyOf": [
            {
              "const": "main",
              "type": "string"
            },
            {
              "const": "isolated",
              "type": "string"
            }
          ]
        },
        "wakeMode": {
          "anyOf": [
            {
              "const": "next-heartbeat",
              "type": "string"
            },
            {
              "const": "now",
              "type": "string"
            }
          ]
        },
        "payload": {
          "anyOf": [
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "text"
              ],
              "properties": {
                "kind": {
                  "const": "systemEvent",
                  "type": "string"
                },
                "text": {
                  "minLength": 1,
                  "type": "string"
                }
              }
            },
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "message"
              ],
              "properties": {
                "kind": {
                  "const": "agentTurn",
                  "type": "string"
                },
                "message": {
                  "minLength": 1,
                  "type": "string"
                },
                "model": {
                  "type": "string"
                },
                "thinking": {
                  "type": "string"
                },
                "timeoutSeconds": {
                  "minimum": 1,
                  "type": "integer"
                },
                "deliver": {
                  "type": "boolean"
                },
                "provider": {
                  "anyOf": [
                    {
                      "const": "last",
                      "type": "string"
                    },
                    {
                      "minLength": 1,
                      "type": "string"
                    }
                  ]
                },
                "to": {
                  "type": "string"
                },
                "bestEffortDeliver": {
                  "type": "boolean"
                }
              }
            }
          ]
        },
        "isolation": {
          "additionalProperties": false,
          "type": "object",
          "properties": {
            "postToMainPrefix": {
              "type": "string"
            }
          }
        },
        "state": {
          "additionalProperties": false,
          "type": "object",
          "properties": {
            "nextRunAtMs": {
              "minimum": 0,
              "type": "integer"
            },
            "runningAtMs": {
              "minimum": 0,
              "type": "integer"
            },
            "lastRunAtMs": {
              "minimum": 0,
              "type": "integer"
            },
            "lastStatus": {
              "anyOf": [
                {
                  "const": "ok",
                  "type": "string"
                },
                {
                  "const": "error",
                  "type": "string"
                },
                {
                  "const": "skipped",
                  "type": "string"
                }
              ]
            },
            "lastError": {
              "type": "string"
            },
            "lastDurationMs": {
              "minimum": 0,
              "type": "integer"
            }
          }
        }
      }
    },
    "CronListParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "includeDisabled": {
          "type": "boolean"
        }
      }
    },
    "CronStatusParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {}
    },
    "CronAddParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "schedule",
        "sessionTarget",
        "wakeMode",
        "payload"
      ],
      "properties": {
        "name": {
          "minLength": 1,
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        },
        "schedule": {
          "anyOf": [
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "atMs"
              ],
              "properties": {
                "kind": {
                  "const": "at",
                  "type": "string"
                },
                "atMs": {
                  "minimum": 0,
                  "type": "integer"
                }
              }
            },
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "everyMs"
              ],
              "properties": {
                "kind": {
                  "const": "every",
                  "type": "string"
                },
                "everyMs": {
                  "minimum": 1,
                  "type": "integer"
                },
                "anchorMs": {
                  "minimum": 0,
                  "type": "integer"
                }
              }
            },
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "expr"
              ],
              "properties": {
                "kind": {
                  "const": "cron",
                  "type": "string"
                },
                "expr": {
                  "minLength": 1,
                  "type": "string"
                },
                "tz": {
                  "type": "string"
                }
              }
            }
          ]
        },
        "sessionTarget": {
          "anyOf": [
            {
              "const": "main",
              "type": "string"
            },
            {
              "const": "isolated",
              "type": "string"
            }
          ]
        },
        "wakeMode": {
          "anyOf": [
            {
              "const": "next-heartbeat",
              "type": "string"
            },
            {
              "const": "now",
              "type": "string"
            }
          ]
        },
        "payload": {
          "anyOf": [
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "text"
              ],
              "properties": {
                "kind": {
                  "const": "systemEvent",
                  "type": "string"
                },
                "text": {
                  "minLength": 1,
                  "type": "string"
                }
              }
            },
            {
              "additionalProperties": false,
              "type": "object",
              "required": [
                "kind",
                "message"
              ],
              "properties": {
                "kind": {
                  "const": "agentTurn",
                  "type": "string"
                },
                "message": {
                  "minLength": 1,
                  "type": "string"
                },
                "model": {
                  "type": "string"
                },
                "thinking": {
                  "type": "string"
                },
                "timeoutSeconds": {
                  "minimum": 1,
                  "type": "integer"
                },
                "deliver": {
                  "type": "boolean"
                },
                "provider": {
                  "anyOf": [
                    {
                      "const": "last",
                      "type": "string"
                    },
                    {
                      "minLength": 1,
                      "type": "string"
                    }
                  ]
                },
                "to": {
                  "type": "string"
                },
                "bestEffortDeliver": {
                  "type": "boolean"
                }
              }
            }
          ]
        },
        "isolation": {
          "additionalProperties": false,
          "type": "object",
          "properties": {
            "postToMainPrefix": {
              "type": "string"
            }
          }
        }
      }
    },
    "CronUpdateParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "patch"
      ],
      "properties": {
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "patch": {
          "additionalProperties": false,
          "type": "object",
          "properties": {
            "name": {
              "minLength": 1,
              "type": "string"
            },
            "description": {
              "type": "string"
            },
            "enabled": {
              "type": "boolean"
            },
            "schedule": {
              "anyOf": [
                {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "kind",
                    "atMs"
                  ],
                  "properties": {
                    "kind": {
                      "const": "at",
                      "type": "string"
                    },
                    "atMs": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                },
                {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "kind",
                    "everyMs"
                  ],
                  "properties": {
                    "kind": {
                      "const": "every",
                      "type": "string"
                    },
                    "everyMs": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "anchorMs": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                },
                {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "kind",
                    "expr"
                  ],
                  "properties": {
                    "kind": {
                      "const": "cron",
                      "type": "string"
                    },
                    "expr": {
                      "minLength": 1,
                      "type": "string"
                    },
                    "tz": {
                      "type": "string"
                    }
                  }
                }
              ]
            },
            "sessionTarget": {
              "anyOf": [
                {
                  "const": "main",
                  "type": "string"
                },
                {
                  "const": "isolated",
                  "type": "string"
                }
              ]
            },
            "wakeMode": {
              "anyOf": [
                {
                  "const": "next-heartbeat",
                  "type": "string"
                },
                {
                  "const": "now",
                  "type": "string"
                }
              ]
            },
            "payload": {
              "anyOf": [
                {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "kind",
                    "text"
                  ],
                  "properties": {
                    "kind": {
                      "const": "systemEvent",
                      "type": "string"
                    },
                    "text": {
                      "minLength": 1,
                      "type": "string"
                    }
                  }
                },
                {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "kind",
                    "message"
                  ],
                  "properties": {
                    "kind": {
                      "const": "agentTurn",
                      "type": "string"
                    },
                    "message": {
                      "minLength": 1,
                      "type": "string"
                    },
                    "model": {
                      "type": "string"
                    },
                    "thinking": {
                      "type": "string"
                    },
                    "timeoutSeconds": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "deliver": {
                      "type": "boolean"
                    },
                    "provider": {
                      "anyOf": [
                        {
                          "const": "last",
                          "type": "string"
                        },
                        {
                          "minLength": 1,
                          "type": "string"
                        }
                      ]
                    },
                    "to": {
                      "type": "string"
                    },
                    "bestEffortDeliver": {
                      "type": "boolean"
                    }
                  }
                }
              ]
            },
            "isolation": {
              "additionalProperties": false,
              "type": "object",
              "properties": {
                "postToMainPrefix": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "CronRemoveParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "CronRunParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "mode": {
          "anyOf": [
            {
              "const": "due",
              "type": "string"
            },
            {
              "const": "force",
              "type": "string"
            }
          ]
        }
      }
    },
    "CronRunsParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "minLength": 1,
          "type": "string"
        },
        "limit": {
          "minimum": 1,
          "maximum": 5000,
          "type": "integer"
        }
      }
    },
    "CronRunLogEntry": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "ts",
        "jobId",
        "action"
      ],
      "properties": {
        "ts": {
          "minimum": 0,
          "type": "integer"
        },
        "jobId": {
          "minLength": 1,
          "type": "string"
        },
        "action": {
          "const": "finished",
          "type": "string"
        },
        "status": {
          "anyOf": [
            {
              "const": "ok",
              "type": "string"
            },
            {
              "const": "error",
              "type": "string"
            },
            {
              "const": "skipped",
              "type": "string"
            }
          ]
        },
        "error": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "runAtMs": {
          "minimum": 0,
          "type": "integer"
        },
        "durationMs": {
          "minimum": 0,
          "type": "integer"
        },
        "nextRunAtMs": {
          "minimum": 0,
          "type": "integer"
        }
      }
    },
    "LogsTailParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "cursor": {
          "minimum": 0,
          "type": "integer"
        },
        "limit": {
          "minimum": 1,
          "maximum": 5000,
          "type": "integer"
        },
        "maxBytes": {
          "minimum": 1,
          "maximum": 1000000,
          "type": "integer"
        }
      }
    },
    "LogsTailResult": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "file",
        "cursor",
        "size",
        "lines"
      ],
      "properties": {
        "file": {
          "minLength": 1,
          "type": "string"
        },
        "cursor": {
          "minimum": 0,
          "type": "integer"
        },
        "size": {
          "minimum": 0,
          "type": "integer"
        },
        "lines": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "truncated": {
          "type": "boolean"
        },
        "reset": {
          "type": "boolean"
        }
      }
    },
    "ChatHistoryParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "sessionKey"
      ],
      "properties": {
        "sessionKey": {
          "minLength": 1,
          "type": "string"
        },
        "limit": {
          "minimum": 1,
          "maximum": 1000,
          "type": "integer"
        }
      }
    },
    "ChatSendParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "sessionKey",
        "message",
        "idempotencyKey"
      ],
      "properties": {
        "sessionKey": {
          "minLength": 1,
          "type": "string"
        },
        "message": {
          "minLength": 1,
          "type": "string"
        },
        "thinking": {
          "type": "string"
        },
        "deliver": {
          "type": "boolean"
        },
        "attachments": {
          "type": "array",
          "items": {}
        },
        "timeoutMs": {
          "minimum": 0,
          "type": "integer"
        },
        "idempotencyKey": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "ChatAbortParams": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "sessionKey"
      ],
      "properties": {
        "sessionKey": {
          "minLength": 1,
          "type": "string"
        },
        "runId": {
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "ChatEvent": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "runId",
        "sessionKey",
        "seq",
        "state"
      ],
      "properties": {
        "runId": {
          "minLength": 1,
          "type": "string"
        },
        "sessionKey": {
          "minLength": 1,
          "type": "string"
        },
        "seq": {
          "minimum": 0,
          "type": "integer"
        },
        "state": {
          "anyOf": [
            {
              "const": "delta",
              "type": "string"
            },
            {
              "const": "final",
              "type": "string"
            },
            {
              "const": "aborted",
              "type": "string"
            },
            {
              "const": "error",
              "type": "string"
            }
          ]
        },
        "message": {},
        "errorMessage": {
          "type": "string"
        },
        "usage": {},
        "stopReason": {
          "type": "string"
        }
      }
    },
    "UpdateRunParams": {
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "sessionKey": {
          "type": "string"
        },
        "note": {
          "type": "string"
        },
        "restartDelayMs": {
          "minimum": 0,
          "type": "integer"
        },
        "timeoutMs": {
          "minimum": 1,
          "type": "integer"
        }
      }
    },
    "TickEvent": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "ts"
      ],
      "properties": {
        "ts": {
          "minimum": 0,
          "type": "integer"
        }
      }
    },
    "ShutdownEvent": {
      "additionalProperties": false,
      "type": "object",
      "required": [
        "reason"
      ],
      "properties": {
        "reason": {
          "minLength": 1,
          "type": "string"
        },
        "restartExpectedMs": {
          "minimum": 0,
          "type": "integer"
        }
      }
    }
  }
}