{
  "$id": "https://sessionpipe.org/schema/v1/control-hello.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "harnesses": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]{0,39}$"
      }
    },
    "modes": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "sdk",
          "waiter",
          "turn",
          "inbox",
          "api",
          "resume",
          "fork"
        ]
      }
    },
    "keys": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 16,
        "maxLength": 1400,
        "pattern": "^[A-Za-z0-9_-]*$"
      }
    },
    "version": {
      "type": "string",
      "maxLength": 40
    },
    "waiting": {
      "maxItems": 500,
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]{0,39}:[A-Za-z0-9._:-]{1,128}$"
      }
    },
    "folders": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 1024
      }
    },
    "mode": {
      "type": "string",
      "enum": [
        "safe",
        "auto",
        "inherit"
      ]
    },
    "accounts": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "harness": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]{0,39}$"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "email": {
            "type": "string",
            "maxLength": 254
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "signed_in": {
            "type": "boolean"
          }
        },
        "required": [
          "harness",
          "id"
        ]
      }
    },
    "files": {
      "type": "boolean"
    },
    "prompt_files": {
      "type": "boolean"
    },
    "start": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]{0,39}$"
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "permissions": {
            "minItems": 1,
            "maxItems": 4,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "read",
                "safe",
                "edits",
                "auto"
              ]
            },
            "uniqueItems": true
          },
          "permission": {
            "type": "string",
            "enum": [
              "read",
              "safe",
              "edits",
              "auto",
              "inherit"
            ]
          },
          "models": {
            "maxItems": 50,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@[\\]-]*$"
            }
          },
          "any_model": {
            "type": "boolean"
          }
        },
        "required": [
          "permissions",
          "permission"
        ]
      },
      "maxProperties": 50
    },
    "key_types": {
      "minItems": 1,
      "maxItems": 2,
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "passkey",
          "device"
        ]
      }
    },
    "pool": {
      "type": "object",
      "properties": {
        "on": {
          "type": "boolean"
        },
        "harness": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]{0,39}$"
        },
        "accounts": {
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9._:-]{1,128}$"
              },
              "email": {
                "type": "string",
                "maxLength": 254
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "enabled": {
                "type": "boolean"
              },
              "status": {
                "type": "string",
                "enum": [
                  "ready",
                  "limited",
                  "error",
                  "disabled"
                ]
              },
              "current": {
                "type": "boolean"
              },
              "until": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}(?:Z))$"
              },
              "windows": {
                "minItems": 1,
                "maxItems": 8,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[a-z0-9_]{1,64}$"
                    },
                    "used_percent": {
                      "type": "number",
                      "minimum": 0
                    },
                    "resets_at": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}(?:Z))$"
                    },
                    "window_minutes": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "id",
                    "used_percent"
                  ],
                  "additionalProperties": {}
                }
              },
              "limited_by": {
                "type": "string",
                "pattern": "^[a-z0-9_]{1,64}$"
              }
            },
            "required": [
              "id",
              "enabled",
              "status"
            ]
          }
        }
      },
      "required": [
        "on",
        "harness",
        "accounts"
      ]
    },
    "ask": {
      "type": "boolean"
    },
    "handoff": {
      "type": "boolean"
    }
  },
  "required": [
    "name",
    "harnesses",
    "modes",
    "keys",
    "version"
  ]
}
