{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://limecloud.github.io/agentapp/schemas/app-install.schema.json",
  "title": "Agent App Install Contract",
  "type": "object",
  "required": ["install"],
  "properties": {
    "install": {
      "type": "object",
      "required": ["modes"],
      "properties": {
        "modes": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["in_lime", "standalone", "runtime_backed", "web_host"]
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "runtime": {
          "type": "object",
          "properties": {
            "minVersion": { "type": "string" },
            "protocolVersion": { "type": "string" },
            "clientPackage": { "$ref": "#/$defs/clientPackage" },
            "sidecar": { "$ref": "#/$defs/sidecar" },
            "releaseManifest": { "$ref": "#/$defs/releaseManifest" },
            "distribution": {
              "type": "object",
              "properties": {
                "standalone": {
                  "type": "object",
                  "properties": {
                    "embedRuntime": { "type": "boolean" },
                    "shell": { "type": "string" },
                    "bundleSidecar": { "type": "boolean" }
                  },
                  "additionalProperties": true
                },
                "runtimeBacked": {
                  "type": "object",
                  "properties": {
                    "requires": { "type": "string" },
                    "minVersion": { "type": "string" },
                    "resolveFromManifest": { "type": "boolean" }
                  },
                  "additionalProperties": true
                }
              },
              "additionalProperties": true
            }
          },
          "additionalProperties": true
        },
        "standalone": {
          "type": "object",
          "properties": {
            "shell": { "type": "string" },
            "bundleId": { "type": "string" },
            "platforms": {
              "type": "array",
              "items": { "type": "string", "enum": ["macos", "windows", "linux"] },
              "uniqueItems": true
            },
            "autoUpdate": { "type": "boolean" }
          },
          "additionalProperties": true
        },
        "runtimeBacked": {
          "type": "object",
          "properties": {
            "requires": { "type": "string" },
            "minVersion": { "type": "string" },
            "clientPackage": { "$ref": "#/$defs/clientPackage" },
            "releaseManifest": { "$ref": "#/$defs/releaseManifest" }
          },
          "additionalProperties": true
        },
        "branding": {
          "type": "object",
          "properties": {
            "name": { "type": "string", "minLength": 1 },
            "icon": { "type": "string" },
            "windowTitle": { "type": "string" }
          },
          "additionalProperties": true
        },
        "compatibility": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    }
  },
  "$defs": {
    "clientPackage": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "version": { "type": "string" },
        "protocolVersion": { "type": "string" }
      },
      "additionalProperties": true
    },
    "sidecar": {
      "type": "object",
      "properties": {
        "binary": { "type": "string" },
        "packagedResource": { "type": "string" },
        "platforms": {
          "type": "array",
          "items": { "type": "string", "enum": ["darwin-arm64", "darwin-x64", "win32-x64", "linux-x64"] },
          "uniqueItems": true
        },
        "sha256Required": { "type": "boolean" }
      },
      "additionalProperties": true
    },
    "releaseManifest": {
      "type": "object",
      "properties": {
        "path": { "type": "string" },
        "url": { "type": "string" },
        "sha256Required": { "type": "boolean" },
        "allowEnvOverrideInProduction": { "type": "boolean", "const": false }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
